substanced
substanced copied to clipboard
AddFileView should support extended schema
Content types which extend File
w/ custom properties cannot currently get those properties processed cleanly by the base add view.
Its add_success
should pop()
the known/mandatory properties, and then, when calling _makeOb
, pass the remainder via **kw
. E.g.:
def add_success(self, appstruct):
name = appstruct.pop('name')
title = appstruct.pop('title', None)
filedata = appstruct.pop('file')
mimetype = appstruct.pop('mimetype', USE_MAGIC)
stream = None
filename = None
if filedata:
filename = filedata['filename']
stream = filedata['fp']
if stream:
stream.seek(0)
else:
stream = None
name = name or filename
fileob = self._makeob(stream, title, mimetype, **appstruct)
self.context[name] = fileob
return HTTPFound(self.request.sdiapi.mgmt_path(self.context))