Exemplo n.º 1
0
 def params(self):
     """ A combined :class:`MultiDict` with values from :attr:`forms` and
         :attr:`GET`. File-uploads are not included. """
     params = MultiDict(self.GET)
     for key, value in self.forms.iterallitems():
         params[key] = value
     return params
Exemplo n.º 2
0
 def GET(self):
     """ The QUERY_STRING parsed into an instance of :class:`MultiDict`. """
     data = parse_qs(self.query_string, keep_blank_values=True)
     get = self.environ['mole.get'] = MultiDict()
     for key, values in data.iteritems():
         for value in values:
             get[key] = value
     return get
Exemplo n.º 3
0
    def files(self):
        """ File uploads parsed into an instance of :class:`MultiDict`.

            This property contains file uploads parsed from an
            `multipart/form-data` encoded POST request body. The values are
            instances of :class:`cgi.FieldStorage`.
        """
        files = MultiDict()
        for name, item in self.POST.iterallitems():
            if hasattr(item, 'filename'):
                files[name] = item
        return files
Exemplo n.º 4
0
    def forms(self):
        """ POST form values parsed into an instance of :class:`MultiDict`.

            This property contains form values parsed from an `url-encoded`
            or `multipart/form-data` encoded POST request bidy. The values are
            native strings.
        """
        forms = MultiDict()
        for name, item in self.POST.iterallitems():
            if not hasattr(item, 'filename'):
                forms[name] = item
        return forms
Exemplo n.º 5
0
 def POST(self):
     """ The combined values from :attr:`forms` and :attr:`files`. Values are
         either strings (form values) or instances of
         :class:`cgi.FieldStorage` (file uploads).
     """
     post = MultiDict()
     safe_env = {'QUERY_STRING': ''}  # Build a safe environment for cgi
     for key in ('REQUEST_METHOD', 'CONTENT_TYPE', 'CONTENT_LENGTH'):
         if key in self.environ: safe_env[key] = self.environ[key]
     if NCTextIOWrapper:
         fb = NCTextIOWrapper(self.body,
                              encoding='ISO-8859-1',
                              newline='\n')
     else:
         fb = self.body
     data = cgi.FieldStorage(fp=fb,
                             environ=safe_env,
                             keep_blank_values=True)
     for item in data.list or []:
         post[item.name] = item if item.filename else item.value
     return post
Exemplo n.º 6
0
 def append(self, key, value):
     return MultiDict.append(self, self.httpkey(key), str(value))
Exemplo n.º 7
0
 def get(self, key, default=None, index=-1):
     return MultiDict.get(self, self.httpkey(key), default, index)
Exemplo n.º 8
0
 def __delitem__(self, key):
     return MultiDict.__delitem__(self, self.httpkey(key))
Exemplo n.º 9
0
 def __contains__(self, key):
     return MultiDict.__contains__(self, self.httpkey(key))
Exemplo n.º 10
0
 def __getitem__(self, key): return MultiDict.__getitem__(self, self.httpkey(key))
 def __delitem__(self, key): return MultiDict.__delitem__(self, self.httpkey(key))
Exemplo n.º 11
0
 def getall(self, key): return MultiDict.getall(self, self.httpkey(key))
 def httpkey(self, key): return str(key).replace('_','-').title()
Exemplo n.º 12
0
 def replace(self, key, value): return MultiDict.replace(self, self.httpkey(key), str(value))
 def getall(self, key): return MultiDict.getall(self, self.httpkey(key))
Exemplo n.º 13
0
 def append(self, key, value): return MultiDict.append(self, self.httpkey(key), str(value))
 def replace(self, key, value): return MultiDict.replace(self, self.httpkey(key), str(value))
Exemplo n.º 14
0
 def get(self, key, default=None, index=-1): return MultiDict.get(self, self.httpkey(key), default, index)
 def append(self, key, value): return MultiDict.append(self, self.httpkey(key), str(value))
Exemplo n.º 15
0
 def __delitem__(self, key): return MultiDict.__delitem__(self, self.httpkey(key))
 def __setitem__(self, key, value): self.replace(key, value)
Exemplo n.º 16
0
 def replace(self, key, value):
     return MultiDict.replace(self, self.httpkey(key), str(value))
Exemplo n.º 17
0
 def getall(self, key):
     return MultiDict.getall(self, self.httpkey(key))
Exemplo n.º 18
0
 def __contains__(self, key): return MultiDict.__contains__(self, self.httpkey(key))
 def __getitem__(self, key): return MultiDict.__getitem__(self, self.httpkey(key))