[Erp5-report] r39409 arnaud.fontaine - in /erp5/trunk/products/ERP5Type: Core/ Dynamic/ Too...

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Oct 21 00:03:45 CEST 2010


Author: arnaud.fontaine
Date: Thu Oct 21 00:03:45 2010
New Revision: 39409

URL: http://svn.erp5.org?rev=39409&view=rev
Log:
ZODB Property Sheets:
* Generate accessor holders for Document property_sheets.
* Fix naming of methods in portaltypeclass.
* Add export method for Constraints following other Documents.


Modified:
    erp5/trunk/products/ERP5Type/Core/CategoryExistenceConstraint.py
    erp5/trunk/products/ERP5Type/Core/PropertyExistenceConstraint.py
    erp5/trunk/products/ERP5Type/Dynamic/portaltypeclass.py
    erp5/trunk/products/ERP5Type/Tool/PropertySheetTool.py
    erp5/trunk/products/ERP5Type/mixin/constraint.py

Modified: erp5/trunk/products/ERP5Type/Core/CategoryExistenceConstraint.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Core/CategoryExistenceConstraint.py?rev=39409&r1=39408&r2=39409&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Core/CategoryExistenceConstraint.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Core/CategoryExistenceConstraint.py [utf8] Thu Oct 21 00:03:45 2010
@@ -30,7 +30,7 @@
 
 from Products.ERP5Type.mixin.constraint import ConstraintMixin
 from AccessControl import ClassSecurityInfo
-from Products.ERP5Type import Permissions
+from Products.ERP5Type import Permissions, PropertySheet
 
 class CategoryExistenceConstraint(ConstraintMixin):
   """
@@ -46,6 +46,11 @@ class CategoryExistenceConstraint(Constr
   security = ClassSecurityInfo()
   security.declareObjectProtected(Permissions.AccessContentsInformation)
 
+  property_sheets = (PropertySheet.SimpleItem,
+                     PropertySheet.Predicate,
+                     PropertySheet.Reference,
+                     PropertySheet.CategoryExistenceConstraint)
+
   _message_id_list = [ 'message_category_not_set',
                        'message_category_not_associated_with_portal_type' ]
   message_category_not_set = "Category existence error for base"\

Modified: erp5/trunk/products/ERP5Type/Core/PropertyExistenceConstraint.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Core/PropertyExistenceConstraint.py?rev=39409&r1=39408&r2=39409&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Core/PropertyExistenceConstraint.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Core/PropertyExistenceConstraint.py [utf8] Thu Oct 21 00:03:45 2010
@@ -30,7 +30,7 @@
 
 from Products.ERP5Type.mixin.constraint import ConstraintMixin
 from AccessControl import ClassSecurityInfo
-from Products.ERP5Type import Permissions
+from Products.ERP5Type import Permissions, PropertySheet
 
 class PropertyExistenceConstraint(ConstraintMixin):
   """
@@ -52,6 +52,11 @@ class PropertyExistenceConstraint(Constr
   security = ClassSecurityInfo()
   security.declareObjectProtected(Permissions.AccessContentsInformation)
 
+  property_sheets = (PropertySheet.SimpleItem,
+                     PropertySheet.Predicate,
+                     PropertySheet.Reference,
+                     PropertySheet.PropertyExistenceConstraint)
+
   # Define by default error messages
   _message_id_list = ['message_no_such_property',
                       'message_property_not_set']

Modified: erp5/trunk/products/ERP5Type/Dynamic/portaltypeclass.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Dynamic/portaltypeclass.py?rev=39409&r1=39408&r2=39409&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Dynamic/portaltypeclass.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Dynamic/portaltypeclass.py [utf8] Thu Oct 21 00:03:45 2010
@@ -57,21 +57,11 @@ def _import_class(classpath):
   except StandardError:
     raise ImportError('Could not import document class %s' % classpath)
 
-# FIXME: bad name
-def _create_accessor_holder_class(property_sheet_tool,
-                                  property_sheet_module,
-                                  property_sheet_name):
-  """
-  If the given Property Sheet exists in portal_property_sheets, then
-  generate its accessor holder
-  """
-
-# FIXME: bad name
-def _fill_accessor_holder_list(accessor_holder_list,
-                               create_accessor_holder_func,
-                               property_sheet_name_set,
-                               accessor_holder_module,
-                               property_sheet_module):
+def _fillAccessorHolderList(accessor_holder_list,
+                            create_accessor_holder_func,
+                            property_sheet_name_set,
+                            accessor_holder_module,
+                            property_sheet_module):
   """
   Fill the accessor holder list with the given Property Sheets (which
   could be coming either from the filesystem or ZODB)
@@ -167,28 +157,6 @@ def portal_type_factory(portal_type_name
       finally:
         del klass
 
-  import erp5
-
-#broken#    # Initialize filesystem Property Sheets accessor holders
-#broken#    _fill_accessor_holder_list(
-#broken#      accessor_holder_list,
-#broken#      site.portal_property_sheets.createFilesystemPropertySheetAccessorHolder,
-#broken#      set(portal_type.getTypePropertySheetList() or ()),
-#broken#      erp5.filesystem_accessor_holder,
-#broken#      FilesystemPropertySheet)
-#broken#
-#broken#    # Initialize ZODB Property Sheets accessor holders
-#broken#    _fill_accessor_holder_list(
-#broken#      accessor_holder_list,
-#broken#      site.portal_property_sheets.createZodbPropertySheetAccessorHolder,
-#broken#      set(portal_type.getTypeZodbPropertySheetList() or ()),
-#broken#      erp5.zodb_accessor_holder,
-#broken#      site.portal_property_sheets)
-
-    #LOG("ERP5Type.Dynamic", INFO,
-    #    "%s: accessor_holder_list: %s" % (portal_type_name,
-    #                                      accessor_holder_list))
-
   if type_class is not None:
     type_class = document_class_registry.get(type_class)
   if type_class is None:
@@ -196,6 +164,42 @@ def portal_type_factory(portal_type_name
 
   type_class = _import_class(type_class)
 
+  ## Disabled because there will be no commit of
+  ## type_zodb_property_sheet, only use for testing ATM
+
+  # import erp5
+
+  # # Initialize filesystem Property Sheets accessor holders
+  # _fillAccessorHolderList(
+  #   accessor_holder_list,
+  #   site.portal_property_sheets.createFilesystemPropertySheetAccessorHolder,
+  #   set(portal_type.getTypePropertySheetList() or ()),
+  #   erp5.filesystem_accessor_holder,
+  #   FilesystemPropertySheet)
+
+  # # Initialize ZODB Property Sheets accessor holders
+  # _fillAccessorHolderList(
+  #   accessor_holder_list,
+  #   site.portal_property_sheets.createZodbPropertySheetAccessorHolder,
+  #   set(portal_type.getTypeZodbPropertySheetList() or ()),
+  #   erp5.zodb_accessor_holder,
+  #   site.portal_property_sheets)
+
+  # # XXX: for now, we have PropertySheet classes defined in
+  # #      property_sheets attribute of Document, but there will be only
+  # #      string at the end
+  # from Products.ERP5Type.Base import getClassPropertyList
+  # _fillAccessorHolderList(
+  #   accessor_holder_list,
+  #   site.portal_property_sheets.createFilesystemPropertySheetAccessorHolder,
+  #   [ klass.__name__ for klass in getClassPropertyList(type_class) ],
+  #   erp5.filesystem_accessor_holder,
+  #   FilesystemPropertySheet)
+
+  # LOG("ERP5Type.Dynamic", INFO,
+  #     "%s: accessor_holder_list: %s" % (portal_type_name,
+  #                                       accessor_holder_list))
+
   mixin_path_list = []
   if mixin_list:
     mixin_path_list = map(mixin_class_registry.__getitem__, mixin_list)
@@ -245,6 +249,7 @@ def initializeDynamicModules():
   erp5.filesystem_accessor_holder = ModuleType("erp5.filesystem_accessor_holder")
   sys.modules["erp5.filesystem_accessor_holder"] = erp5.filesystem_accessor_holder
 
+  # FIXME: JPS: rename to dynamic_module.newDynamicModule()?
   portal_type_container = dynamicmodule.dynamicmodule('erp5.portal_type',
                                                       portal_type_loader)
 
@@ -286,8 +291,7 @@ def initializeDynamicModules():
   erp5.temp_portal_type = dynamicmodule.dynamicmodule('erp5.temp_portal_type',
                                                    temp_portal_type_loader)
 
-# FIXME: bad name
-def _clear_accessor_holder_module(module):
+def _clearAccessorHolderModule(module):
   """
   Clear the given accessor holder module (either for filesystem or
   ZODB)
@@ -340,7 +344,7 @@ def synchronizeDynamicModules(context, f
       type(ExtensionBase).__init__(klass, klass)
 
   # Clear accessor holders of ZODB Property Sheets
-  _clear_accessor_holder_module(erp5.zodb_accessor_holder)
+  _clearAccessorHolderModule(erp5.zodb_accessor_holder)
 
   # Clear accessor holders of filesystem Property Sheets
-  _clear_accessor_holder_module(erp5.filesystem_accessor_holder)
+  _clearAccessorHolderModule(erp5.filesystem_accessor_holder)

Modified: erp5/trunk/products/ERP5Type/Tool/PropertySheetTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Tool/PropertySheetTool.py?rev=39409&r1=39408&r2=39409&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Tool/PropertySheetTool.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Tool/PropertySheetTool.py [utf8] Thu Oct 21 00:03:45 2010
@@ -152,20 +152,17 @@ class PropertySheetTool(BaseTool):
 
     for property in property_sheet.contentValues():
       portal_type = property.getPortalType()
+      property_definition = property.exportToFilesystemDefinition()
 
-      if portal_type == "Standard Property" or \
-         portal_type == "Acquired Property":
-        properties.append(property.exportToFilesystemDefinition())
-
-      elif portal_type == "Category Property":
-        categories.append(property.getId())
-
-      elif portal_type == "Dynamic Category Property":
-        categories.append(property.exportToFilesystemDefinition())
+      if portal_type == "Category Property" or \
+         portal_type == "Dynamic Category Property":
+        categories.append(property_definition)
 
       elif portal_type.endswith('Constraint'):
-        from Acquisition import aq_base
-        constraints.append(aq_base(property.asContext()))
+        constraints.append(property_definition)
+
+      else:
+        properties.append(property_definition)
 
     return (properties, categories, constraints)
 

Modified: erp5/trunk/products/ERP5Type/mixin/constraint.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/mixin/constraint.py?rev=39409&r1=39408&r2=39409&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/mixin/constraint.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/mixin/constraint.py [utf8] Thu Oct 21 00:03:45 2010
@@ -85,3 +85,15 @@ class ConstraintMixin(Predicate):
     Default method is to call checkConsistency with fixit set to 1
     """
     return self.checkConsistency(obj, fixit=1, **kw)
+
+  security.declareProtected(Permissions.AccessContentsInformation,
+                            'exportToFilesystemDefinition')
+  def exportToFilesystemDefinition(self):
+    """
+    Return a temporary copy of the constraint object (with acquisition
+    wrapping removed) in order to maintain compatibility and be able
+    to use setDefaultProperties
+
+    XXX: remove as soon as the code is stable
+    """
+    return self.asContext().aq_base




More information about the Erp5-report mailing list