[CMF-checkins] CVS: CMF/CMFDefault - DublinCore.py:1.16

Tres Seaver tseaver@zope.com
Sun, 17 Mar 2002 20:47:15 -0500


Update of /cvs-repository/CMF/CMFDefault
In directory cvs.zope.org:/tmp/cvs-serv23801/CMFDefault

Modified Files:
	DublinCore.py 
Log Message:


  - Added forwared-compatibility for "old" content (pre CMF 1.0!;
    Tracker #454, thanks to Lucas Hofman for the patch).


=== CMF/CMFDefault/DublinCore.py 1.15 => 1.16 ===
     def Subject( self ):
         "Dublin Core element - resource keywords"
-        return self.subject
+        return getattr( self, 'subject', () ) # compensate for *old* content
 
     security.declarePublic( 'Publisher' )
     def Publisher( self ):
@@ -111,7 +111,8 @@
         """
             Dublin Core element - date resource created.
         """
-        return self.creation_date.ISO()
+        # return unknown if never set properly
+        return self.creation_date and self.creation_date.ISO() or 'Unknown'
     
     security.declarePublic( 'EffectiveDate' )
     def EffectiveDate( self ):
@@ -179,6 +180,8 @@
             WebDAV needs this to do the Right Thing (TM).
         """
         return self.Format()
+    __FLOOR_DATE = DateTime( 1000, 0 ) # alwasy effective
+
 
     security.declarePublic( 'isEffective' )
     def isEffective( self, date ):
@@ -200,10 +203,10 @@
             Dublin Core element - date resource created,
               returned as DateTime.
         """
-        return self.creation_date
+        # allow for non-existent creation_date, existed always
+        date = getattr( self, 'creation_date', None )
+        return date is None and self.__FLOOR_DATE or date
     
-    __FLOOR_DATE = DateTime( 1000, 0 ) # alwasy effective
-
     security.declarePublic( 'effective' )
     def effective( self ):
         """