Ejemplo n.º 1
0
    _guarded_writes = 1

    def __init__(self, **kw):
        self.update(kw)

    def __setitem__(self, key, value):
        key = str(key)
        if key.startswith('_'):
            raise ValueError, ('Object key %s is invalid. '
                               'Keys may not begin with an underscore.' % `key`)
        self.__dict__[key] = value

    def update(self, d):
        for key in d.keys():
            # Ignore invalid keys, rather than raising an exception.
            try:
                skey = str(key)
            except:
                continue
            if skey==key and not skey.startswith('_'):
                self.__dict__[skey] = d[key]

    def __hash__(self):
        return id(self)

security.declarePublic('Object')
def Object(**kw):
    return _Object(**kw)

security.apply(globals())
Ejemplo n.º 2
0
    import Image
  
  # Save image in temp-folder
  context = img.aq_parent
  tempfolder = tempfile.mktemp()
  filepath = _fileutil.getOSPath('%s/%s'%(tempfolder, img.filename))
  _fileutil.exportObj(img, filepath)
  
  # Resize image
  im = Image.open(filepath)
  im = im.convert('RGB')
  im.convert('RGB').save(filepath, "JPEG", quality=qual, optimize=True)
  
  # Read optimized image from file-system
  f = open(filepath, 'rb')
  data = f.read()
  result = {'data':data,'filename':img.filename}
  f.close()
  
  # Remove temp-folder and images
  _fileutil.remove(tempfolder, deep=1)
  
  # Returns resulting image
  image = standard.ImageFromData(context, result['data'], result['filename'])
  return image


security.apply(globals())

################################################################################
Ejemplo n.º 3
0
                        Default on Python 2: Latin1 when ``use_unicode``
                        is off, utf8 otherwise
                        Default on Python 3: utf8

    :bool: auto_create_db -- If the database given in ``connection_string``
                             does not exist, create it automatically.
                             Default: False.

    :int: timeout -- The connect timeout for the connection in seconds.
                             Default: None

    :object: REQUEST -- The currently active Zope request object.
                        Default: None.
    """
    self._setObject(
        id,
        Connection(id,
                   title,
                   connection_string,
                   check,
                   use_unicode=use_unicode,
                   charset=charset,
                   auto_create_db=auto_create_db,
                   timeout=timeout))

    if REQUEST is not None:
        return self.manage_main(self, REQUEST)


mod_security.apply(globals())
Ejemplo n.º 4
0
    __call__ = __str__

    def PrincipiaSearchSource(self):
        ''' Support for searching - the document's contents are searched.
        '''
        return self.source

    def manage_historyCompare(self,
                              rev1,
                              rev2,
                              REQUEST,
                              historyComparisonResults=''):
        return ZReST.inheritedAttribute('manage_historyCompare')(
            self,
            rev1,
            rev2,
            REQUEST,
            historyComparisonResults=html_diff(rev1.source, rev2.source))

    def manage_editProperties(self, REQUEST):
        """ re-render the page after changing the properties (encodings!!!) """
        result = PropertyManager.manage_editProperties(self, REQUEST)
        self._clear_cache()
        return result


InitializeClass(ZReST)
modulesecurity.apply(globals())

# vim: set filetype=python ts=4 sw=4 et si
Ejemplo n.º 5
0
    def __str__(self):
        ''' Stringfy .. return the source
        '''
        return self.quotedHTML(self.source)

    __call__ = __str__

    def PrincipiaSearchSource(self):
        ''' Support for searching - the document's contents are searched.
        '''
        return self.source

    def manage_historyCompare(self, rev1, rev2, REQUEST,
                              historyComparisonResults=''):
        return ZReST.inheritedAttribute('manage_historyCompare')(
            self, rev1, rev2, REQUEST,
            historyComparisonResults=html_diff(rev1.source, rev2.source))

    def manage_editProperties(self, REQUEST):
        """ re-render the page after changing the properties (encodings!!!) """
        result = PropertyManager.manage_editProperties(self, REQUEST)        
        self._clear_cache()
        return result


InitializeClass(ZReST)
modulesecurity.apply(globals())


# vim: set filetype=python ts=4 sw=4 et si