Exemplo n.º 1
0
    def _set_request(self, request):
        """
        Assign raw request data to the form

        :arg request_data: raw request data (e.g. request.POST)
        :type request_data: Dictionary (dotted or nested or dotted or MultiDict)
        """
        self._request = request
        request_data = getattr(request, self.method.upper())
        # Decode request data according to the request's charset.
        request_data = UnicodeMultiDict(
            request_data, encoding=util.get_post_charset(request))
        # Remove the sequence factory data from the request
        for k in request_data.keys():
            if '*' in k:
                request_data.pop(k)
        # We need the _request_data to be populated so sequences know how many
        # items they have (i.e. .fields method on a sequence uses the number of
        # values on the _request_data)

        # Convert request data to a dottedish friendly representation
        request_data = _unflatten_request_data(request_data)
        self._request_data = dotted(request_data)
        self._request_data = dotted(
            self.widget.pre_parse_incoming_request_data(
                self.structure, request_data))
Exemplo n.º 2
0
Arquivo: forms.py Projeto: ish/formish
 def _get_request_data(self):
     """
     Retrieve previously set request_data or return the defaults in
     request_data format.
     """
     if self._request_data is not None:
         return dotted(self._request_data)
     self._request_data = dotted(self.widget.to_request_data(self.structure, self._defaults))
     return dotted(self._request_data)
Exemplo n.º 3
0
 def _get_request_data(self):
     """
     Retrieve previously set request_data or return the defaults in
     request_data format.
     """
     if self._request_data is not None:
         return dotted(self._request_data)
     self._request_data = dotted(
         self.widget.to_request_data(self.structure, self._defaults))
     return dotted(self._request_data)
Exemplo n.º 4
0
def dotted_or_emptydict(d):
    if d is None:
        return {}
    try:
        return dotted(d)
    except TypeError:
        return d
Exemplo n.º 5
0
Arquivo: forms.py Projeto: ish/formish
    def _set_request_data(self, request_data):
        """
        Assign raw request data to the form

        :arg request_data: raw request data (e.g. request.POST)
        :type request_data: Dictionary (dotted or nested or dotted or MultiDict)
        """
        self._request_data = dotted(request_data)
Exemplo n.º 6
0
    def _set_request_data(self, request_data):
        """
        Assign raw request data to the form

        :arg request_data: raw request data (e.g. request.POST)
        :type request_data: Dictionary (dotted or nested or dotted or MultiDict)
        """
        self._request_data = dotted(request_data)
Exemplo n.º 7
0
Arquivo: forms.py Projeto: ish/formish
 def get_item_data_values(self, name=None):
     """
     get all of the item data values
     """
     data = dotted({})
     for key, value in self.item_data.items():
         if name is not None and value.has_key(name):
             data[key] = value[name]
         else:
             data[key] = value
     return data
Exemplo n.º 8
0
 def get_item_data_values(self, name=None):
     """
     get all of the item data values
     """
     data = dotted({})
     for key, value in self.item_data.items():
         if name is not None and value.has_key(name):
             data[key] = value[name]
         else:
             data[key] = value
     return data
Exemplo n.º 9
0
Arquivo: forms.py Projeto: ish/formish
    def _set_request(self, request):
        """
        Assign raw request data to the form

        :arg request_data: raw request data (e.g. request.POST)
        :type request_data: Dictionary (dotted or nested or dotted or MultiDict)
        """
        self._request = request
        request_data = getattr(request, self.method.upper())
        # Decode request data according to the request's charset.
        request_data = UnicodeMultiDict(request_data,
                                        encoding=util.get_post_charset(request))
        # Remove the sequence factory data from the request
        for k in request_data.keys():
            if '*' in k:
                request_data.pop(k)
        # We need the _request_data to be populated so sequences know how many
        # items they have (i.e. .fields method on a sequence uses the number of
        # values on the _request_data)

        # Convert request data to a dottedish friendly representation
        request_data = _unflatten_request_data(request_data)
        self._request_data = dotted(request_data)
        self._request_data = dotted(self.widget.pre_parse_incoming_request_data(self.structure,request_data))
Exemplo n.º 10
0
def add_id_and_attr_to_files(data, session=None):
    if not isinstance(data, dict):
        return data
    dd = dotted(data)
    for k,f in flatten(data):
        if isinstance(f,File):
            if '_id' in dd and '_rev' in dd:
                if session:
                    f.file = AttachmentFileLike(session, dd['_id'], f.id)
                f.doc_id = dd['_id']
                f.rev = dd['_rev']
            segments = k.split('.')
            for n in xrange(1,len(segments)):
                subpath = '.'.join(segments[:-n])
                if '_id' in dd[subpath] and '_rev' in dd[subpath]:
                    f.doc_id = dd[subpath]['_id']
                    f.rev = dd[subpath]['_rev']
    return data
Exemplo n.º 11
0
Arquivo: forms.py Projeto: ish/formish
 def _get_defaults(self):
     """ Get the raw default data """
     return dotted(self._defaults)
Exemplo n.º 12
0
 def _get_defaults(self):
     """ Get the raw default data """
     return dotted(self._defaults)