Exemple #1
0
def processInputs(request, charsets=None):
    """Process the values in request.form to decode strings to unicode, using
    the passed-in list of charsets. If none are passed in, look up the user's
    preferred charsets. The default is to use utf-8.
    """

    if IProcessedRequest.providedBy(request):
        return

    if charsets is None:
        envadapter = IUserPreferredCharsets(request, None)
        if envadapter is None:
            charsets = ['utf-8']
        else:
            charsets = envadapter.getPreferredCharsets() or ['utf-8']

    for name, value in request.form.items():
        if not (isCGI_NAME(name) or name.startswith('HTTP_')):
            if isinstance(value, str):
                request.form[name] = _decode(value, charsets)
            elif isinstance(value, (list, tuple,)):
                newValue = []
                for val in value:
                    if isinstance(val, str):
                        val = _decode(val, charsets)
                    newValue.append(val)

                if isinstance(value, tuple):
                    newValue = tuple(value)

                request.form[name] = newValue

    interface.alsoProvides(request, IProcessedRequest)
def processInputs(request, charsets=None):
    """ Override Products.Five.browser.decode.processInputs
    """
    if charsets is None:
        envadapter = IUserPreferredCharsets(request)
        charsets = envadapter.getPreferredCharsets() or ['utf-8']

    for name, value in request.form.items():
        if not (isCGI_NAME(name) or name.startswith('HTTP_')):
            # XXX => really dirty

            if name=='groups' or name=='users':
                request.form[name] = value

            elif isinstance(value, str):
                request.form[name] = _decode(value, charsets)

            elif isinstance(value, list):
                request.form[name] = [_decode(val, charsets)
                                      for val in value
                                      if isinstance(val, str)]

            elif isinstance(value, tuple):
                request.form[name] = tuple([_decode(val, charsets)
                                            for val in value
                                            if isinstance(val, str)])
Exemple #3
0
def processInputs(request, charsets=None):
    """Process the values in request.form to decode strings to unicode, using
    the passed-in list of charsets. If none are passed in, look up the user's
    preferred charsets. The default is to use utf-8.
    """

    if IProcessedRequest.providedBy(request):
        return

    if charsets is None:
        envadapter = IUserPreferredCharsets(request, None)
        if envadapter is None:
            charsets = ['utf-8']
        else:
            charsets = envadapter.getPreferredCharsets() or ['utf-8']

    for name, value in request.form.items():
        if not (isCGI_NAME(name) or name.startswith('HTTP_')):
            if isinstance(value, str):
                request.form[name] = _decode(value, charsets)
            elif isinstance(value, (list, tuple,)):
                newValue = []
                for val in value:
                    if isinstance(val, str):
                        val = _decode(val, charsets)
                    newValue.append(val)

                if isinstance(value, tuple):
                    newValue = tuple(value)

                request.form[name] = newValue

    interface.alsoProvides(request, IProcessedRequest)
Exemple #4
0
def processInputs(request, charsets=None):
    if charsets is None:
        envadapter = IUserPreferredCharsets(request)
        charsets = envadapter.getPreferredCharsets() or ['utf-8']
    
    for name, value in request.form.items():
        if (not (isCGI_NAME(name) or name.startswith('HTTP_'))
            and isinstance(value, str)):
            request.form[name] = _decode(value, charsets)
Exemple #5
0
 def _processInputs(self):
     request = self.request
     for name, value in request.form.items():
         if not (isCGI_NAME(name) or name.startswith('HTTP_')):
             if isinstance(value, str):
                 request.form[name] = self._decode(value)
             elif isinstance(value, list):
                 request.form[name] = [ self._decode(val)
                                        for val in value
                                        if isinstance(val, str) ]
             elif isinstance(value, tuple):
                 request.form[name] = tuple([ self._decode(val)
                                              for val in value
                                              if isinstance(val, str) ])
Exemple #6
0
 def _processInputs(self):
     request = self.request
     for name, value in request.form.items():
         if not (isCGI_NAME(name) or name.startswith('HTTP_')):
             if isinstance(value, str):
                 request.form[name] = self._decode(value)
             elif isinstance(value, list):
                 request.form[name] = [
                     self._decode(val) for val in value
                     if isinstance(val, str)
                 ]
             elif isinstance(value, tuple):
                 request.form[name] = tuple([
                     self._decode(val) for val in value
                     if isinstance(val, str)
                 ])
Exemple #7
0
def processInputs(request, charsets=None):
    if charsets is None:
        envadapter = IUserPreferredCharsets(request)
        charsets = envadapter.getPreferredCharsets() or ['utf-8']

    for name, value in request.form.items():
        if not (isCGI_NAME(name) or name.startswith('HTTP_')):
            if isinstance(value, str):
                request.form[name] = _decode(value, charsets)
            elif isinstance(value, list):
                request.form[name] = [ _decode(val, charsets)
                                       for val in value
                                       if isinstance(val, str) ]
            elif isinstance(value, tuple):
                request.form[name] = tuple([ _decode(val, charsets)
                                             for val in value
                                             if isinstance(val, str) ])
def processInputs(request, charsets=None):
    if charsets is None:
        envadapter = IUserPreferredCharsets(request)
        charsets = envadapter.getPreferredCharsets() or ['utf-8']

    for name, value in request.form.items():
        if not (isCGI_NAME(name) or name.startswith('HTTP_')):
            if isinstance(value, str):
                request.form[name] = _decode(value, charsets)
            elif isinstance(value, list):
                request.form[name] = [ _decode(val, charsets)
                                       for val in value
                                       if isinstance(val, str) ]
            elif isinstance(value, tuple):
                request.form[name] = tuple([ _decode(val, charsets)
                                             for val in value
                                             if isinstance(val, str) ])
Exemple #9
0
 def _processInputs(self):
     request = self.request
     for name, value in request.form.items():
         if (not (isCGI_NAME(name) or name.startswith('HTTP_'))
                 and isinstance(value, str)):
             request.form[name] = self._decode(value)
Exemple #10
0
 def _processInputs(self):
     request = self.request
     for name, value in request.form.items():
         if (not (isCGI_NAME(name) or name.startswith('HTTP_'))
             and isinstance(value, str)):
             request.form[name] = self._decode(value)