Commit 7a46d5fb authored by Nicolas Delaby's avatar Nicolas Delaby

* Move getFilename to File, because Document class is deprecated.

* Declare security on Accessor
* Honour default argument if equals to None



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@41907 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 01f1fdc0
...@@ -788,11 +788,3 @@ class Document(DocumentExtensibleTraversableMixin, XMLObject, UrlMixin, ...@@ -788,11 +788,3 @@ class Document(DocumentExtensibleTraversableMixin, XMLObject, UrlMixin,
return container.isIndexContent(self) return container.isIndexContent(self)
return False return False
# backward compatibility
def getFilename(self, default=None):
if self.hasFilename():
return self._baseGetFilename(default)
elif self.hasSourceReference():
return self._baseGetSourceReference(default)
else:
return default
...@@ -47,6 +47,8 @@ def _unpackData(data): ...@@ -47,6 +47,8 @@ def _unpackData(data):
""" """
return str(data) return str(data)
_MARKER = object()
class File(Document, CMFFile): class File(Document, CMFFile):
""" """
A File can contain raw data which can be uploaded and downloaded. A File can contain raw data which can be uploaded and downloaded.
...@@ -273,6 +275,23 @@ class File(Document, CMFFile): ...@@ -273,6 +275,23 @@ class File(Document, CMFFile):
return 'text/plain', '' return 'text/plain', ''
raise NotImplementedError raise NotImplementedError
# backward compatibility
security.declareProtected(Permissions.AccessContentsInformation, 'getFilename')
def getFilename(self, default=_MARKER):
"""Fallback on getSourceReference as it was used
before to store filename property
"""
if self.hasFilename():
if default is _MARKER:
return self._baseGetFilename()
else:
return self._baseGetFilename(default)
else:
if default is _MARKER:
return self._baseGetSourceReference()
else:
return self._baseGetSourceReference(default)
# CMFFile also brings the IContentishInterface on CMF 2.2, remove it. # CMFFile also brings the IContentishInterface on CMF 2.2, remove it.
removeIContentishInterface(File) removeIContentishInterface(File)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment