Ejemplo n.º 1
0
    def deserialize(self):
        if self._path:
            return self._path
        data = FieldRenderer.deserialize(self)
        if isinstance(data, cgi.FieldStorage):
            filename = normalized_basename(data.filename)
            self._path = self.relative_path(filename)
            filepath = os.path.join(self.storage_path,
                                    self._path.replace('/', os.sep))
            dirname = os.path.dirname(filepath)
            if not os.path.isdir(dirname):
                os.makedirs(dirname)
            fd = open(filepath, 'wb')
            shutil.copyfileobj(data.file, fd)
            fd.close()
            return self._path
        checkbox_name = '%s--remove' % self.name
        if not data and not self.params.has_key(checkbox_name):
            data = getattr(self.field.model, self.field.name)

        # get value from old_value if needed
        old_value = '%s--old' % self.name
        checkbox_name = '%s--remove' % self.name
        if not data and not self.params.has_key(checkbox_name) \
                    and self.params.has_key(old_value):
            return self.params[old_value]
        return data is not None and data or ''
Ejemplo n.º 2
0
 def deserialize(self):
     """ override ImageFieldRenderer deserialize """
     if self._path:
         return self._path
     data = FieldRenderer.deserialize(self)
     if isinstance(data, cgi.FieldStorage):
         info = ip.process_image(data.file)
         self._path = info['uri']
         return self._path
     checkbox_name = '%s--remove' % self.name
     if not data and not self.params.has_key(checkbox_name):
         data = getattr(self.field.model, self.field.name)
     return self._path
Ejemplo n.º 3
0
 def __init__(self, field):
     self.__templates = None
     
     FieldRenderer.__init__(self, field)
Ejemplo n.º 4
0
    def __init__(self, field):
        self.__templates = None

        FieldRenderer.__init__(self, field)