Exemplo n.º 1
0
 def saveAttributes(self, ctx, form, data, language):
     # We need to do some manual file required checking to work around a
     # forms issue.
     if data.get('image') is None and getattr(self.original, 'image', None) is None:
         raise forms.FieldRequiredError('Required', fieldName='image')
     # Copy the original file back if no new file is specified
     if data.get('image') is None:
         data['image'] = self.original.image
     return DefaultContentEditor.saveAttributes(self, ctx, form, data, language)
Exemplo n.º 2
0
    def saveAttributes(self, ctx, form, data, language):

        # Copy the original file back if no new file is specified
        for assetName in self.assetNames:
            fileId = getattr(self.original, assetName, None)
            if data.get(assetName) is None:
                data[assetName] = fileId
            else:
                # Store data in external table
                storeSession = util.getStoreSession(ctx)
                d = storeFile(storeSession, fileId, self.original.id, self.original.version, assetName, data[assetName])
                d = defer.waitForDeferred(d)
                yield d
                fileId = d.getResult()
                data[assetName] = fileId

        d = DefaultContentEditor.saveAttributes(self, ctx, form, data, language)
        d = defer.waitForDeferred(d)
        yield d
        yield d.getResult()
Exemplo n.º 3
0
    def getForm(self, ctx, language, plugin, immutable):

        form = DefaultContentEditor.getForm(self, ctx, language, plugin, immutable)
        self.updateFormAssets(plugin, form)
        return form