[Erp5-report] r41183 arnaud.fontaine - in /erp5/trunk/products/ERP5Type: ./ PropertySheet/ ...

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Dec 7 07:35:49 CET 2010


Author: arnaud.fontaine
Date: Tue Dec  7 07:35:48 2010
New Revision: 41183

URL: http://svn.erp5.org?rev=41183&view=rev
Log:
Enable generation of accessor holders for ZODB Property Sheets and use
TypePropertySheetList which now contains both ZODB and filesystem
Property Sheets (where the former is used in favor of the latter)

Modified:
    erp5/trunk/products/ERP5Type/Base.py
    erp5/trunk/products/ERP5Type/ERP5Type.py
    erp5/trunk/products/ERP5Type/PropertySheet/BaseType.py
    erp5/trunk/products/ERP5Type/dynamic/portal_type_class.py
    erp5/trunk/products/ERP5Type/tests/testDynamicClassGeneration.py

Modified: erp5/trunk/products/ERP5Type/Base.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Base.py?rev=41183&r1=41182&r2=41183&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Base.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Base.py [utf8] Tue Dec  7 07:35:48 2010
@@ -575,6 +575,14 @@ def initializePortalTypeDynamicPropertie
       ptype_object.updatePropertySheetDefinitionDict(ps_definition_dict)
 
     for base in getClassPropertyList(klass):
+      # FIXME: With ZODB Property Sheets, there should only be the
+      # name of the Property Sheet as a string. aq_dynamic should not
+      # be necessary as soon as all the Documents and Property Sheets
+      # have been migrated. This is kept for backward compatility with
+      # the filesystem Property Sheet (see ERP5Type.dynamic.portal_type_class)
+      if isinstance(base, basestring):
+        continue
+
       for list_name, current_list in ps_definition_dict.items():
         try:
           current_list += getattr(base, list_name, ())

Modified: erp5/trunk/products/ERP5Type/ERP5Type.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/ERP5Type.py?rev=41183&r1=41182&r2=41183&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/ERP5Type.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/ERP5Type.py [utf8] Tue Dec  7 07:35:48 2010
@@ -608,8 +608,13 @@ class ERP5TypeInformation(XMLObject,
     security.declareProtected(Permissions.AccessContentsInformation,
                               'getAvailablePropertySheetList')
     def getAvailablePropertySheetList(self):
-      return sorted(k for k in PropertySheet.__dict__
-                      if not k.startswith('__'))
+      property_sheet_set = set([k for k in PropertySheet.__dict__
+                                if not k.startswith('__')])
+
+      property_sheet_tool = self.getPortalObject().portal_property_sheets
+      property_sheet_set.update(property_sheet_tool.objectIds())
+
+      return sorted(property_sheet_set)
 
     security.declareProtected(Permissions.AccessContentsInformation,
                               'getAvailableConstraintList')

Modified: erp5/trunk/products/ERP5Type/PropertySheet/BaseType.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/PropertySheet/BaseType.py?rev=41183&r1=41182&r2=41183&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/PropertySheet/BaseType.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/PropertySheet/BaseType.py [utf8] Tue Dec  7 07:35:48 2010
@@ -101,6 +101,7 @@ class BaseType:
         , 'mode':       'w'
         , 'label':      'Property Sheets'
         , 'select_variable':'getAvailablePropertySheetList'
+        , 'default':    ()
          },
         { 'id':         'type_base_category'
         , 'storage_id': 'base_category_list' # CMF Compatibility

Modified: erp5/trunk/products/ERP5Type/dynamic/portal_type_class.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/dynamic/portal_type_class.py?rev=41183&r1=41182&r2=41183&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/dynamic/portal_type_class.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/dynamic/portal_type_class.py [utf8] Tue Dec  7 07:35:48 2010
@@ -222,28 +222,28 @@ def generatePortalTypeClass(portal_type_
 
     property_sheet_set = set()
 
-    #### Waiting for Yoshinori's advice before enabling this code
-    # if portal_type is not None:
-    #   # Get the Property Sheets defined on the portal_type
-    #   property_sheet_set.update(portal_type.getTypeZodbPropertySheetList() \
-    #                             or ())
-
-    #### The Property Sheets specified in the property_sheets
-    #### attribute of a Document are only filesystem-based, thus for
-    #### now it has to be done in the Portal Types themselves
-    # # Get the Property Sheets defined on the document and its bases
-    # # recursively
-    # from Products.ERP5Type.Base import getClassPropertyList
-    # for property_sheet in getClassPropertyList(klass):
-    #   if isinstance(property_sheet, basestring):
-    #     property_sheet_name = property_sheet
-    #   # FIXME: The Property Sheets of a document should be given as a
-    #   # string from now on, but to avoid changing all the code now, we
-    #   # just get the class name of the filesystem Property Sheet
-    #   else:
-    #     property_sheet_name = property_sheet.__name__
-
-    #   property_sheet_set.add(property_sheet_name)
+    if portal_type is not None:
+      # Get the Property Sheets defined on the portal_type and use the
+      # ZODB Property Sheet rather than the filesystem only if it
+      # exists in ZODB
+      zodb_property_sheet_set = set(site.portal_property_sheets.objectIds())
+      for property_sheet in portal_type.getTypePropertySheetList():
+        if property_sheet in zodb_property_sheet_set:
+          property_sheet_set.add(property_sheet)
+
+    # Get the Property Sheets defined on the document and its bases
+    # recursively. Fallback on the filesystem Property Sheet only and
+    # only if the ZODB Property Sheet does not exist
+    from Products.ERP5Type.Base import getClassPropertyList
+    for property_sheet in getClassPropertyList(klass):
+      # If the Property Sheet is a string, then this is a ZODB
+      # Property Sheet
+      #
+      # NOTE: The Property Sheets of a document should be given as a
+      #       string from now on
+      if isinstance(property_sheet, basestring):
+        property_sheet_name = property_sheet
+        property_sheet_set.add(property_sheet_name)
 
     import erp5
 

Modified: erp5/trunk/products/ERP5Type/tests/testDynamicClassGeneration.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/testDynamicClassGeneration.py?rev=41183&r1=41182&r2=41183&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/testDynamicClassGeneration.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/tests/testDynamicClassGeneration.py [utf8] Tue Dec  7 07:35:48 2010
@@ -33,7 +33,7 @@ import transaction
 
 from Products.ERP5Type.dynamic.portal_type_class import synchronizeDynamicModules
 from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
-from Products.ERP5Type.tests.backportUnittest import expectedFailure, skip
+from Products.ERP5Type.tests.backportUnittest import expectedFailure
 
 from zope.interface import Interface, implementedBy
 
@@ -545,9 +545,7 @@ class TestZodbPropertySheet(ERP5TypeTest
         id='Test Migration',
         portal_type='Base Type',
         type_class='Folder',
-        # XXX: to be renamed to type_property_sheet_list as soon as
-        #      the migration has been finished
-        type_zodb_property_sheet_list=('TestMigration',),
+        type_property_sheet_list=('TestMigration',),
         type_base_category_list=('test_category_existence_constraint',),
         type_allowed_content_type_list=('Content Existence Constraint',))
 
@@ -596,20 +594,18 @@ class TestZodbPropertySheet(ERP5TypeTest
     portal = self.getPortal()
     person_type = portal.portal_types.Person
 
-    self.failIf('TestMigration' in \
-                (person_type.getTypeZodbPropertySheetList() or []))
+    self.failIf('TestMigration' in person_type.getTypePropertySheetList())
 
     new_person = None
     try:
       # Assign ZODB test Property Sheet to the existing Person type
       # and create a new Person, this should generate the test
       # accessor holder which should be in the Person type inheritance
-      person_type.setTypeZodbPropertySheetList('TestMigration')
+      person_type.setTypePropertySheetList('TestMigration')
 
       transaction.commit()
 
-      self.assertTrue('TestMigration' in \
-                      person_type.getTypeZodbPropertySheetList())
+      self.assertTrue('TestMigration' in person_type.getTypePropertySheetList())
 
       # The accessor holder will be generated once the new Person will
       # be created as Person type has test Property Sheet
@@ -678,7 +674,7 @@ class TestZodbPropertySheet(ERP5TypeTest
       # '_setType*'
       transaction.commit()
 
-      person_type.setTypeZodbPropertySheetList(None)
+      person_type.setTypePropertySheetList(())
 
       if new_person is not None:
         portal.person_module.deleteContent(new_person.getId())
@@ -689,15 +685,14 @@ class TestZodbPropertySheet(ERP5TypeTest
     # unassigned by creating a new person in Person module
     transaction.commit()
 
-    self.failIf('TestMigration' in \
-                (person_type.getTypeZodbPropertySheetList() or []))
+    self.failIf('TestMigration' in person_type.getTypePropertySheetList())
 
     try:
       new_person = portal.person_module.newContent(
         id='testAssignZodbPropertySheet', portal_type='Person')
 
-      self.failIfHasAttribute(new_person, 'getTestStandardPropertyAssign')
       self.failIfHasAttribute(erp5.accessor_holder, 'TestMigration')
+      self.failIfHasAttribute(new_person, 'getTestStandardPropertyAssign')
 
     finally:
       if new_person is not None:
@@ -1019,9 +1014,6 @@ class TestZodbPropertySheet(ERP5TypeTest
                           self.test_module.setTitle,
                           'my_property_type_validity_constraint_title')
 
-TestZodbPropertySheet = skip("ZODB Property Sheets code is not enabled yet")(
-  TestZodbPropertySheet)
-
 from Products.ERP5Type import PropertySheet
 from Products.CMFCore.Expression import Expression
 



More information about the Erp5-report mailing list