[Erp5-report] r41192 arnaud.fontaine - /erp5/trunk/products/ERP5Type/dynamic/

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Dec 7 12:24:49 CET 2010


Author: arnaud.fontaine
Date: Tue Dec  7 12:24:48 2010
New Revision: 41192

URL: http://svn.erp5.org?rev=41192&view=rev
Log:
When loading the Portal Type, check whether portal_property_sheets is
not missing, which may arise when the BT has not been upgraded yet

Modified:
    erp5/trunk/products/ERP5Type/dynamic/portal_type_class.py

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=41192&r1=41191&r2=41192&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 12:24:48 2010
@@ -220,30 +220,35 @@ def generatePortalTypeClass(portal_type_
 
     property_sheet_generating_portal_type_set.add(portal_type_name)
 
+    property_sheet_tool = getattr(site, 'portal_property_sheets', None)
+
     property_sheet_set = set()
 
-    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)
+    # The Property Sheet Tool may be None if the code is updated but
+    # the BT has not been upgraded yet with portal_property_sheets
+    if property_sheet_tool is not None:
+      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(property_sheet_tool.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
 
@@ -251,10 +256,10 @@ def generatePortalTypeClass(portal_type_
       # Initialize ZODB Property Sheets accessor holders
       _fillAccessorHolderList(
         accessor_holder_list,
-        site.portal_property_sheets.createZodbPropertySheetAccessorHolder,
+        property_sheet_tool.createZodbPropertySheetAccessorHolder,
         property_sheet_set,
         erp5.accessor_holder,
-        site.portal_property_sheets)
+        property_sheet_tool)
 
     property_sheet_generating_portal_type_set.remove(portal_type_name)
 



More information about the Erp5-report mailing list