[Checkins] SVN: zope.schema/trunk/ The attribute used for the Object Field validation, ``__schema_being_validated``, has been renamed ``_v_schema_being_validated``. As a volatile attribute, it won't be persisted, avoiding the possible read/write conflicts.

Souheil CHELFOUH souheil at chelfouh.com
Thu Dec 23 14:18:50 EST 2010


Log message for revision 119076:
  The attribute used for the Object Field validation, ``__schema_being_validated``, has been renamed ``_v_schema_being_validated``. As a volatile attribute, it won't be persisted, avoiding the possible read/write conflicts.
  
  

Changed:
  U   zope.schema/trunk/CHANGES.txt
  U   zope.schema/trunk/src/zope/schema/_field.py

-=-
Modified: zope.schema/trunk/CHANGES.txt
===================================================================
--- zope.schema/trunk/CHANGES.txt	2010-12-23 16:52:59 UTC (rev 119075)
+++ zope.schema/trunk/CHANGES.txt	2010-12-23 19:18:49 UTC (rev 119076)
@@ -5,6 +5,12 @@
 3.7.1 (unreleased)
 ------------------
 
+- The validation token, used in the validation of schema with Object
+  Field to avoid infinite recursion, has been renamed.
+  ``__schema_being_validated`` became ``_v_schema_being_validated``,
+  a volatile attribute, to avoid persistency and therefore,
+  read/write conflicts.
+
 - Don't allow "[\]^`" in DottedName.
   https://bugs.launchpad.net/zope.schema/+bug/191236
 

Modified: zope.schema/trunk/src/zope/schema/_field.py
===================================================================
--- zope.schema/trunk/src/zope/schema/_field.py	2010-12-23 16:52:59 UTC (rev 119075)
+++ zope.schema/trunk/src/zope/schema/_field.py	2010-12-23 19:18:49 UTC (rev 119076)
@@ -463,10 +463,10 @@
         return errors
     # if `value` is part of a cyclic graph, we need to break the cycle to avoid
     # infinite recursion.
-    if hasattr(value, '__schema_being_validated'):
+    if hasattr(value, '_v_schema_being_validated'):
         return errors
     # Mark the value as being validated.
-    value.__schema_being_validated = True
+    value._v_schema_being_validated = True
     # (If we have gotten here, we know that `value` provides an interface
     # other than zope.interface.Interface;
     # iow, we can rely on the fact that it is an instance
@@ -485,7 +485,7 @@
                     # property for the given name is not implemented
                     errors.append(SchemaNotFullyImplemented(error))
     finally:
-        delattr(value, '__schema_being_validated')
+        delattr(value, '_v_schema_being_validated')
     return errors
 
 



More information about the checkins mailing list