[Checkins] SVN: zope.schema/trunk/src/zope/schema/ Inocculate zope.schema against a possible future patch to zope.interface making Attributes use __slots__. Add tests for __doc__, interface and queryTaggedValue when cloning.

Brian Sutherland jinty at web.de
Sun Dec 19 07:32:35 EST 2010


Log message for revision 119003:
  Inocculate zope.schema against a possible future patch to zope.interface making Attributes use __slots__. Add tests for __doc__, interface and queryTaggedValue when cloning.

Changed:
  U   zope.schema/trunk/src/zope/schema/_bootstrapfields.py
  U   zope.schema/trunk/src/zope/schema/tests/test_field.py

-=-
Modified: zope.schema/trunk/src/zope/schema/_bootstrapfields.py
===================================================================
--- zope.schema/trunk/src/zope/schema/_bootstrapfields.py	2010-12-18 17:22:44 UTC (rev 119002)
+++ zope.schema/trunk/src/zope/schema/_bootstrapfields.py	2010-12-19 12:32:35 UTC (rev 119003)
@@ -76,6 +76,12 @@
 
     default = ValidatedProperty('default')
 
+    # These were declared as slots in zope.interface, we override them here to
+    # get rid of the dedcriptors so they don't break .bind()
+    __name__ = None
+    interface = None
+    _Element__tagged_values = None
+
     def __init__(self, title=u'', description=u'', __name__='',
                  required=True, readonly=False, constraint=None, default=None,
                  missing_value=__missing_value_marker):

Modified: zope.schema/trunk/src/zope/schema/tests/test_field.py
===================================================================
--- zope.schema/trunk/src/zope/schema/tests/test_field.py	2010-12-18 17:22:44 UTC (rev 119002)
+++ zope.schema/trunk/src/zope/schema/tests/test_field.py	2010-12-19 12:32:35 UTC (rev 119003)
@@ -19,6 +19,7 @@
 from doctest import DocTestSuite
 from unittest import TestCase, TestSuite, makeSuite
 
+from zope.interface import Interface
 from zope.schema import Field, Text, Int
 from zope.schema.interfaces import ValidationError, RequiredMissing
 from zope.schema.interfaces import ConstraintNotSatisfied
@@ -32,6 +33,9 @@
             title=u'Not required field', description=u'',
             readonly=False, required=False)
 
+        field.interface = Interface
+        field.setTaggedValue('a', 'b')
+
         class C(object):
             x=None
 
@@ -39,8 +43,9 @@
         field2 = field.bind(c)
 
         self.assertEqual(field2.context, c)
-        for n in ('__class__', '__name__', 'title', 'description',
-                  'readonly', 'required'):
+        self.assertEqual(field.queryTaggedValue('a'), field2.queryTaggedValue('a'))
+        for n in ('__class__', '__name__', '__doc__', 'title', 'description',
+                  'readonly', 'required', 'interface'):
             self.assertEquals(getattr(field2, n), getattr(field, n), n)
 
     def testValidate(self):



More information about the checkins mailing list