[Zope3-checkins] SVN: Zope3/trunk/ Fix for issue 534: use Tuple instead of List for dublin core attributes to

Martijn Faassen faassen at infrae.com
Fri Aug 18 06:37:04 EDT 2006


Log message for revision 69641:
  Fix for issue 534: use Tuple instead of List for dublin core attributes to 
  be more inline with implementation. Adjust zope.dublincore.property 
  functionality to handle tuples as well.
  

Changed:
  U   Zope3/trunk/doc/CHANGES.txt
  U   Zope3/trunk/src/zope/dublincore/interfaces.py
  U   Zope3/trunk/src/zope/dublincore/property.py

-=-
Modified: Zope3/trunk/doc/CHANGES.txt
===================================================================
--- Zope3/trunk/doc/CHANGES.txt	2006-08-18 10:22:16 UTC (rev 69640)
+++ Zope3/trunk/doc/CHANGES.txt	2006-08-18 10:37:03 UTC (rev 69641)
@@ -16,7 +16,8 @@
         IHTTPVirtualHostChangedEvent, when virtual host parameters are 
         altered.
 
-      - Dublin Core Property and testing
+      - New Dublin Core property object that allows scalar treatment for
+        sequence types. Made it work with both Tuple and List field type.
 
     Restructuring
 
@@ -95,7 +96,7 @@
 
     Much thanks to everyone who contributed to this release:
 
-      Jim Fulton, Dmitry Vasiliev
+      Jim Fulton, Dmitry Vasiliev, Martijn Faassen
 
   ------------------------------------------------------------------
 
@@ -299,13 +300,17 @@
       - Fixed issue 587, make sure that utf-8 is chosen if the
         Accept-Charset header contains '*'.
 
+      - Fixed issue 534: changed interface definition to use Tuple instead of
+        List for creators, subjects and contributors, to be in line with the
+        implementation.
+
     Much thanks to everyone who contributed to this release:
 
       Jim Fulton, Marius Gedminas, Brian Sutherland, Stephan Richter, Dimitry
       Vasiliev, Tim Peters, Zachery Bir, Gary Poster, Egon Frerich, Zhiyun
       (Simon) Hang, Tadashi Matsumoto, Simon Michael, Encople Degoute,
       Shane Hathaway, Bjorn Tillenius, Sam Stainsby, Bernd Dorn,
-      Stuart Bishop
+      Stuart Bishop, Martijn Faassen
 
   ------------------------------------------------------------------
 

Modified: Zope3/trunk/src/zope/dublincore/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/dublincore/interfaces.py	2006-08-18 10:22:16 UTC (rev 69640)
+++ Zope3/trunk/src/zope/dublincore/interfaces.py	2006-08-18 10:37:03 UTC (rev 69641)
@@ -19,7 +19,7 @@
 
 from zope.annotation.interfaces import IAnnotatable
 from zope.interface import Interface
-from zope.schema import Text, TextLine, Datetime, List
+from zope.schema import Text, TextLine, Datetime, Tuple
 
 class IDublinCoreElementItem(Interface):
     """A qualified dublin core element"""
@@ -270,13 +270,13 @@
     """
 
 
-    creators = List(
+    creators = Tuple(
         title = u'Creators',
         description = u"The unqualified Dublin Core 'Creator' element values",
         value_type = TextLine(),
         )
 
-    subjects = List(
+    subjects = Tuple(
         title = u'Subjects',
         description = u"The unqualified Dublin Core 'Subject' element values",
         value_type = TextLine(),
@@ -288,7 +288,7 @@
         u"The first unqualified Dublin Core 'Publisher' element value.",
         )
 
-    contributors = List(
+    contributors = Tuple(
         title = u'Contributors',
         description =
         u"The unqualified Dublin Core 'Contributor' element values",

Modified: Zope3/trunk/src/zope/dublincore/property.py
===================================================================
--- Zope3/trunk/src/zope/dublincore/property.py	2006-08-18 10:22:16 UTC (rev 69640)
+++ Zope3/trunk/src/zope/dublincore/property.py	2006-08-18 10:37:03 UTC (rev 69641)
@@ -55,9 +55,16 @@
         name = self.__name
         inst = IZopeDublinCore(inst)
         field = IZopeDublinCore[name].bind(inst)
-        if (    not isinstance(value, list)
-            and isinstance(field, schema.List)):
-            value = [value]
+        if isinstance(field, schema.List):
+            if isinstance(value, tuple):
+                value = list(value)
+            else:
+                value = [value]
+        elif isinstance(field, schema.Tuple):
+            if isinstance(value, list):
+                value = tuple(value)
+            else:
+                value = (value,)
         field.validate(value)
         if field.readonly and inst.__dict__.has_key(name):
             raise ValueError(name, 'field is readonly')
@@ -93,6 +100,8 @@
         name = self.__name
         inst = IZopeDublinCore(inst)
         field = IZopeDublinCore[name].bind(inst)
+        if isinstance(field, schema.Tuple):
+            value = tuple(value)
         field.validate(value)
         if field.readonly and inst.__dict__.has_key(name):
             raise ValueError(name, 'field is readonly')



More information about the Zope3-Checkins mailing list