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)])
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)
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) ])
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(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)