예제 #1
0
 def __init__(self, *args, **kw):
     CNXMLFile.__init__(self, *args, **kw)
     File.__init__(self, *args, **kw)
     # Manually set the ID because File is currently broken and deleting __name__,
     # which is where the id is actually stored.  We should probably migrate this to
     # using the ATCT File, which does work.
     self.__name__ = args[0]
예제 #2
0
    def manage_upload(self, file='', REQUEST=None, idprefix=None):
        """
        Replaces the current contents of the File or Image object with file.

        The file or images contents are replaced with the contents of 'file'.

        Override of OFS.Image version (through parent) to add automatic
        ids, with prefixes.

        A reasonable method to use to set the body of the CNXMLFile, but 'setSource' recommended
        if you don't need to be strictly File-ish.
        """
        # manage_upload can take file-ish as well as str
        read = getattr(file, 'read', None)
        if read:
            cursor = file.tell()   # so we can put the seek back where we found it
            file.seek(0)
            src = file.read()
            file.seek(cursor)
        else:
            src = file

        src = autoIds(src, prefix=idprefix)
        if type(src) is unicode:   # OFS.Image.File._read_data isn't happy with possible unicode
            src = src.encode('utf-8')
        return CNXMLFile.manage_upload(self, file=src, REQUEST=REQUEST)
예제 #3
0
    def manage_edit(self, title, content_type, precondition='',
                    filedata=None, REQUEST=None, idprefix=None):
        """
        Changes the title and content type attributes of the File or Image.

        Override of OFS.Image version (through parent) to add automatic
        ids, with prefixes.

        A reasonable method to use to set the body of the CNXMLFile, but 'setSource' recommended
        if you don't need to be strictly File-ish.
        """
        filedata = autoIds(filedata, prefix=idprefix)
        return CNXMLFile.manage_edit(self, title, content_type, precondition=precondition,
                                     filedata=filedata, REQUEST=REQUEST)
예제 #4
0
 def manage_beforeDelete(self, item, container):
     """Both of my parents have a beforeDelete method"""
     File.manage_beforeDelete(self, item, container)
     CNXMLFile.manage_beforeDelete(self, item, container)
예제 #5
0
 def manage_afterAdd(self, item, container):
     """Both of my parents have an afterAdd method"""
     CNXMLFile.manage_afterAdd(self, item, container)
     File.manage_afterAdd(self, item, container)