fixes for resource/file handling on the management interface
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@1676 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
ec1d6ba538
commit
a1d73273ee
3 changed files with 18 additions and 6 deletions
|
@ -59,14 +59,14 @@ renderingFactories = {
|
||||||
class CustomFileWidget(FileWidget):
|
class CustomFileWidget(FileWidget):
|
||||||
|
|
||||||
def hasInput(self):
|
def hasInput(self):
|
||||||
print 'hasInput', self.request.form.get(self.name)
|
|
||||||
if not self.request.form.get(self.name):
|
if not self.request.form.get(self.name):
|
||||||
return False
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
class ResourceEditForm(EditForm):
|
class ResourceEditForm(EditForm):
|
||||||
|
|
||||||
@Lazy
|
@property
|
||||||
def typeInterface(self):
|
def typeInterface(self):
|
||||||
return IType(self.context).typeInterface
|
return IType(self.context).typeInterface
|
||||||
|
|
||||||
|
@ -78,8 +78,8 @@ class ResourceEditForm(EditForm):
|
||||||
omit = [f for f in typeInterface if f in IBaseResource]
|
omit = [f for f in typeInterface if f in IBaseResource]
|
||||||
fields = FormFields(fields.omit(*omit), typeInterface)
|
fields = FormFields(fields.omit(*omit), typeInterface)
|
||||||
dataField = fields['data']
|
dataField = fields['data']
|
||||||
if IBytes.providedBy(dataField):
|
if IBytes.providedBy(dataField.field):
|
||||||
dataField.customWidget = CustomFileWidget
|
dataField.custom_widget = CustomFileWidget
|
||||||
return fields
|
return fields
|
||||||
|
|
||||||
def setUpWidgets(self, ignore_request=False):
|
def setUpWidgets(self, ignore_request=False):
|
||||||
|
|
|
@ -608,12 +608,26 @@ class IFile(IResourceAdapter, IResourceSchema):
|
||||||
may be downloaded instead.
|
may be downloaded instead.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
data = schema.Bytes(
|
||||||
|
title=_(u'Data'),
|
||||||
|
description=_(u'Resource raw data'),
|
||||||
|
default='',
|
||||||
|
missing_value='',
|
||||||
|
required=False)
|
||||||
|
|
||||||
|
|
||||||
class IExternalFile(IFile):
|
class IExternalFile(IFile):
|
||||||
""" A file whose content (data attribute) is not stored in the ZODB
|
""" A file whose content (data attribute) is not stored in the ZODB
|
||||||
but somewhere else, typically in the file system.
|
but somewhere else, typically in the file system.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
data = schema.Bytes(
|
||||||
|
title=_(u'Data'),
|
||||||
|
description=_(u'Resource raw data'),
|
||||||
|
default='',
|
||||||
|
missing_value='',
|
||||||
|
required=False)
|
||||||
|
|
||||||
|
|
||||||
class IImage(IResourceAdapter):
|
class IImage(IResourceAdapter):
|
||||||
""" A media asset that may be embedded in a (web) page as an image.
|
""" A media asset that may be embedded in a (web) page as an image.
|
||||||
|
|
|
@ -323,8 +323,6 @@ class ExternalFileAdapter(FileAdapter):
|
||||||
return self.context.__name__
|
return self.context.__name__
|
||||||
|
|
||||||
def setData(self, data):
|
def setData(self, data):
|
||||||
if not data:
|
|
||||||
return
|
|
||||||
storageParams = self.storageParams
|
storageParams = self.storageParams
|
||||||
storageName = self.storageName
|
storageName = self.storageName
|
||||||
storage = component.getUtility(IExternalStorage, name=storageName)
|
storage = component.getUtility(IExternalStorage, name=storageName)
|
||||||
|
|
Loading…
Add table
Reference in a new issue