Logo Search packages:      
Sourcecode: zope-attachmentfield version File versions  Download package

def AttachmentField::FlexStorage::FlexStorage::migrateContent (   self,
  oldStorage,
  newStorage,
  content,
  fieldNames,
  out 
)

    Change the storage backend of one content.
    oldStorage is the old storage where we get the data (and remove it)
    newStorage is the storage where we put this data
    content is the content

Definition at line 167 of file FlexStorage.py.

00167                                                                               :
        """
            Change the storage backend of one content.
            oldStorage is the old storage where we get the data (and remove it)
            newStorage is the storage where we put this data
            content is the content
        """
        print >> out, '/'.join(content.getPhysicalPath()), ":",

        for name in fieldNames:
            print >> out, "'%s'" % name,
            f = content.getField(name)
            # error if field has already a content
            #if f.get_size(content) != 0:
            #    raise RuntimeError("already set")

            # get content from old storage and delete old storage
            try:
                value = oldStorage.get(name, content)
            except AttributeError:
                print >> out, "no old value",
                continue

            # Unwrap value
            data = BaseUnit(
                name,
                str(value),
                instance=content,
                filename=getattr(value, "filename", "unknowFilename"),
                mimetype=value.getContentType(),
            )

            ### newStorage.initializeField(content, f) #FIXME: really needed?
            f.set(content, data)
            oldStorage.unset(name, content)
            # unset empty files, this avoid empty files on disk
            if f.get_size(content) == 0:
                print >> out, "no data, so unset",
                f.set(content, "DELETE_FILE")

            print >> out, ".",



Generated by  Doxygen 1.6.0   Back to index