[Erp5-report] r44333 jerome - in /erp5/trunk/products/ERP5Type: ./ Core/

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Mar 16 11:13:47 CET 2011


Author: jerome
Date: Wed Mar 16 11:13:46 2011
New Revision: 44333

URL: http://svn.erp5.org?rev=44333&view=rev
Log:
Quick patch to make getSourceReference and getDestinationReference be some
property accessors like they were prior to property sheets as ERP5 documents.

Modified:
    erp5/trunk/products/ERP5Type/Core/CategoryProperty.py
    erp5/trunk/products/ERP5Type/__init__.py

Modified: erp5/trunk/products/ERP5Type/Core/CategoryProperty.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Core/CategoryProperty.py?rev=44333&r1=44332&r2=44333&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Core/CategoryProperty.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Core/CategoryProperty.py [utf8] Wed Mar 16 11:13:46 2011
@@ -28,6 +28,7 @@
 
 from AccessControl import ClassSecurityInfo
 from Products.ERP5Type import Permissions, PropertySheet
+from Products.ERP5Type import SOURCE_DESTINATION_REFERENCE_LEGACY
 from Products.ERP5Type.XMLObject import XMLObject
 
 from Products.ERP5Type.Accessor.Base import Getter as BaseGetter
@@ -198,9 +199,13 @@ class CategoryProperty(IdAsReferenceMixi
     # then getters
     for id_format, accessor_class in cls.getter_definition_dict.iteritems():
       accessor_name = id_format % uppercase_category_id
-
-      public_accessor = accessor_class(accessor_name, category_id)
-      accessor_holder.registerAccessor(public_accessor, read_permission)
+      # XXX getSourceReference/getDestinationReference are already generated by
+      # 'source_reference' and 'destination_reference' standard properties. To
+      # prevent name conflict, we don't generate them as a category accessor.
+      if not (SOURCE_DESTINATION_REFERENCE_LEGACY and accessor_name in (
+              'getSourceReference', 'getDestinationReference')):
+        public_accessor = accessor_class(accessor_name, category_id)
+        accessor_holder.registerAccessor(public_accessor, read_permission)
 
       # create the private getter on the fly instead of having a definition dict
       # that's twice the size for the same info
@@ -211,6 +216,12 @@ class CategoryProperty(IdAsReferenceMixi
     # and setters
     for id_format, accessor_class in cls.setter_definition_dict.iteritems():
       accessor_name = id_format % uppercase_category_id
+      # XXX setSourceReference/setDestinationReference are already generated by
+      # 'source_reference' and 'destination_reference' standard properties. To
+      # prevent name conflict, we don't generate them as a category accessor.
+      if SOURCE_DESTINATION_REFERENCE_LEGACY and accessor_name in (
+                  'setSourceReference', 'setDestinationReference'):
+        continue
 
       accessor = accessor_class(accessor_name, category_id)
       accessor_holder.registerAccessor(accessor, write_permission)

Modified: erp5/trunk/products/ERP5Type/__init__.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/__init__.py?rev=44333&r1=44332&r2=44333&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/__init__.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/__init__.py [utf8] Wed Mar 16 11:13:46 2011
@@ -34,6 +34,14 @@ from patches import python
 from zLOG import LOG, INFO
 DISPLAY_BOOT_PROCESS = False
 
+# We have a name conflict with source_reference and destination_reference,
+# which are at the same time property accessors for 'source_reference'
+# property, and category accessors (similar to getSourceValue().getReference())
+# When this is set to True, those accessors will be the property accessors.
+# At the time beeing, if it's set to False for document having both category
+# and property, the result seem to be undefined.
+SOURCE_DESTINATION_REFERENCE_LEGACY = True
+
 # This is used to register all Document classes used in ERP5
 # items are class names, values are class paths, e.g.:
 #   'Person' -> 'Products.ERP5.Document.Person.Person'



More information about the Erp5-report mailing list