[CMF-checkins] SVN: CMF/branches/1.6/C Reordered base classes of
File and Image, to allow use of super().
Florent Guillaume
fg at nuxeo.com
Fri Nov 18 07:50:31 EST 2005
Log message for revision 40207:
Reordered base classes of File and Image, to allow use of super().
Changed:
U CMF/branches/1.6/CHANGES.txt
U CMF/branches/1.6/CMFDefault/File.py
U CMF/branches/1.6/CMFDefault/Image.py
U CMF/branches/1.6/CMFDefault/tests/test_Image.py
-=-
Modified: CMF/branches/1.6/CHANGES.txt
===================================================================
--- CMF/branches/1.6/CHANGES.txt 2005-11-18 09:19:59 UTC (rev 40206)
+++ CMF/branches/1.6/CHANGES.txt 2005-11-18 12:50:30 UTC (rev 40207)
@@ -10,3 +10,7 @@
interfaces via bridge
- Back-ported the GenericSetup style of site creation from CMF trunk
+
+ Others
+
+ - Reordered base classes of File and Image, to allow use of super().
Modified: CMF/branches/1.6/CMFDefault/File.py
===================================================================
--- CMF/branches/1.6/CMFDefault/File.py 2005-11-18 09:19:59 UTC (rev 40206)
+++ CMF/branches/1.6/CMFDefault/File.py 2005-11-18 12:50:30 UTC (rev 40207)
@@ -105,10 +105,7 @@
self._getOb(id).manage_upload(file)
-class File( OFS.Image.File
- , PortalContent
- , DefaultDublinCoreImpl
- ):
+class File(PortalContent, OFS.Image.File, DefaultDublinCoreImpl):
"""
A Portal-managed File
"""
@@ -154,6 +151,8 @@
):
OFS.Image.File.__init__( self, id, title, file
, content_type, precondition )
+ self._setId(id)
+ delattr(self, '__name__')
# If no file format has been passed in, rely on what OFS.Image.File
# detected. Unlike Images, which have code to try and pick the content
@@ -166,6 +165,12 @@
, contributors, effective_date, expiration_date
, format, language, rights )
+ # For old instances where bases had OFS.Image.File first,
+ # the id was actually stored in __name__.
+ # getId() will do the correct thing here, as id() is callable
+ def id(self):
+ return self.__name__
+
security.declareProtected(View, 'SearchableText')
def SearchableText(self):
"""
Modified: CMF/branches/1.6/CMFDefault/Image.py
===================================================================
--- CMF/branches/1.6/CMFDefault/Image.py 2005-11-18 09:19:59 UTC (rev 40206)
+++ CMF/branches/1.6/CMFDefault/Image.py 2005-11-18 12:50:30 UTC (rev 40207)
@@ -97,10 +97,7 @@
self._getOb(id).manage_upload(file)
-class Image( OFS.Image.Image
- , PortalContent
- , DefaultDublinCoreImpl
- ):
+class Image(PortalContent, OFS.Image.Image, DefaultDublinCoreImpl):
"""
A Portal-managed Image
"""
@@ -146,6 +143,8 @@
):
OFS.Image.File.__init__( self, id, title, file
, content_type, precondition )
+ self._setId(id)
+ delattr(self, '__name__')
# If no file format has been passed in, rely on what OFS.Image.File
# detected.
@@ -156,6 +155,12 @@
, contributors, effective_date, expiration_date
, format, language, rights )
+ # For old instances where bases had OFS.Image.Image first,
+ # the id was actually stored in __name__.
+ # getId() will do the correct thing here, as id() is callable
+ def id(self):
+ return self.__name__
+
security.declareProtected(View, 'SearchableText')
def SearchableText(self):
"""
Modified: CMF/branches/1.6/CMFDefault/tests/test_Image.py
===================================================================
--- CMF/branches/1.6/CMFDefault/tests/test_Image.py 2005-11-18 09:19:59 UTC (rev 40206)
+++ CMF/branches/1.6/CMFDefault/tests/test_Image.py 2005-11-18 12:50:30 UTC (rev 40207)
@@ -53,6 +53,26 @@
self.site = DummySite('site')
self.site._setObject( 'portal_membership', DummyTool() )
+ def test_getId_on_old_Image_instance(self):
+ image = self.site._setObject( 'testimage', Image('testimage') )
+ self.assertEqual(image.getId(), 'testimage')
+ self.assertEqual(image.id, 'testimage')
+ # Mimick old instance when base classes had OFS.Image.Image first
+ image.__name__ = 'testimage'
+ delattr(image, 'id')
+ self.assertEqual(image.getId(), 'testimage')
+ self.assertEqual(image.id(), 'testimage')
+
+ def test_getId_on_old_File_instance(self):
+ file = self.site._setObject( 'testfile', File('testfile') )
+ self.assertEqual(file.getId(), 'testfile')
+ self.assertEqual(file.id, 'testfile')
+ # Mimick old instance when base classes had OFS.Image.File first
+ file.__name__ = 'testfile'
+ delattr(file, 'id')
+ self.assertEqual(file.getId(), 'testfile')
+ self.assertEqual(file.id(), 'testfile')
+
def test_EditWithEmptyFile(self):
# Test handling of empty file uploads
image = self.site._setObject( 'testimage', Image('testimage') )
More information about the CMF-checkins
mailing list