Commit 041377a4 authored by Arnaud Fontaine's avatar Arnaud Fontaine

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)


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@41183 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 7b7a8c2d
...@@ -575,6 +575,14 @@ def initializePortalTypeDynamicProperties(self, klass, ptype, aq_key, portal): ...@@ -575,6 +575,14 @@ def initializePortalTypeDynamicProperties(self, klass, ptype, aq_key, portal):
ptype_object.updatePropertySheetDefinitionDict(ps_definition_dict) ptype_object.updatePropertySheetDefinitionDict(ps_definition_dict)
for base in getClassPropertyList(klass): 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(): for list_name, current_list in ps_definition_dict.items():
try: try:
current_list += getattr(base, list_name, ()) current_list += getattr(base, list_name, ())
......
...@@ -608,8 +608,13 @@ class ERP5TypeInformation(XMLObject, ...@@ -608,8 +608,13 @@ class ERP5TypeInformation(XMLObject,
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getAvailablePropertySheetList') 'getAvailablePropertySheetList')
def getAvailablePropertySheetList(self): def getAvailablePropertySheetList(self):
return sorted(k for k in PropertySheet.__dict__ property_sheet_set = set([k for k in PropertySheet.__dict__
if not k.startswith('__')) 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, security.declareProtected(Permissions.AccessContentsInformation,
'getAvailableConstraintList') 'getAvailableConstraintList')
......
...@@ -101,6 +101,7 @@ class BaseType: ...@@ -101,6 +101,7 @@ class BaseType:
, 'mode': 'w' , 'mode': 'w'
, 'label': 'Property Sheets' , 'label': 'Property Sheets'
, 'select_variable':'getAvailablePropertySheetList' , 'select_variable':'getAvailablePropertySheetList'
, 'default': ()
}, },
{ 'id': 'type_base_category' { 'id': 'type_base_category'
, 'storage_id': 'base_category_list' # CMF Compatibility , 'storage_id': 'base_category_list' # CMF Compatibility
......
...@@ -222,28 +222,28 @@ def generatePortalTypeClass(portal_type_name): ...@@ -222,28 +222,28 @@ def generatePortalTypeClass(portal_type_name):
property_sheet_set = set() property_sheet_set = set()
#### Waiting for Yoshinori's advice before enabling this code if portal_type is not None:
# if portal_type is not None: # Get the Property Sheets defined on the portal_type and use the
# # Get the Property Sheets defined on the portal_type # ZODB Property Sheet rather than the filesystem only if it
# property_sheet_set.update(portal_type.getTypeZodbPropertySheetList() \ # exists in ZODB
# or ()) zodb_property_sheet_set = set(site.portal_property_sheets.objectIds())
for property_sheet in portal_type.getTypePropertySheetList():
#### The Property Sheets specified in the property_sheets if property_sheet in zodb_property_sheet_set:
#### attribute of a Document are only filesystem-based, thus for property_sheet_set.add(property_sheet)
#### now it has to be done in the Portal Types themselves
# # Get the Property Sheets defined on the document and its bases # Get the Property Sheets defined on the document and its bases
# # recursively # recursively. Fallback on the filesystem Property Sheet only and
# from Products.ERP5Type.Base import getClassPropertyList # only if the ZODB Property Sheet does not exist
# for property_sheet in getClassPropertyList(klass): from Products.ERP5Type.Base import getClassPropertyList
# if isinstance(property_sheet, basestring): for property_sheet in getClassPropertyList(klass):
# property_sheet_name = property_sheet # If the Property Sheet is a string, then this is a ZODB
# # FIXME: The Property Sheets of a document should be given as a # Property Sheet
# # string from now on, but to avoid changing all the code now, we #
# # just get the class name of the filesystem Property Sheet # NOTE: The Property Sheets of a document should be given as a
# else: # string from now on
# property_sheet_name = property_sheet.__name__ if isinstance(property_sheet, basestring):
property_sheet_name = property_sheet
# property_sheet_set.add(property_sheet_name) property_sheet_set.add(property_sheet_name)
import erp5 import erp5
......
...@@ -33,7 +33,7 @@ import transaction ...@@ -33,7 +33,7 @@ import transaction
from Products.ERP5Type.dynamic.portal_type_class import synchronizeDynamicModules from Products.ERP5Type.dynamic.portal_type_class import synchronizeDynamicModules
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase 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 from zope.interface import Interface, implementedBy
...@@ -545,9 +545,7 @@ class TestZodbPropertySheet(ERP5TypeTestCase): ...@@ -545,9 +545,7 @@ class TestZodbPropertySheet(ERP5TypeTestCase):
id='Test Migration', id='Test Migration',
portal_type='Base Type', portal_type='Base Type',
type_class='Folder', type_class='Folder',
# XXX: to be renamed to type_property_sheet_list as soon as type_property_sheet_list=('TestMigration',),
# the migration has been finished
type_zodb_property_sheet_list=('TestMigration',),
type_base_category_list=('test_category_existence_constraint',), type_base_category_list=('test_category_existence_constraint',),
type_allowed_content_type_list=('Content Existence Constraint',)) type_allowed_content_type_list=('Content Existence Constraint',))
...@@ -596,20 +594,18 @@ class TestZodbPropertySheet(ERP5TypeTestCase): ...@@ -596,20 +594,18 @@ class TestZodbPropertySheet(ERP5TypeTestCase):
portal = self.getPortal() portal = self.getPortal()
person_type = portal.portal_types.Person person_type = portal.portal_types.Person
self.failIf('TestMigration' in \ self.failIf('TestMigration' in person_type.getTypePropertySheetList())
(person_type.getTypeZodbPropertySheetList() or []))
new_person = None new_person = None
try: try:
# Assign ZODB test Property Sheet to the existing Person type # Assign ZODB test Property Sheet to the existing Person type
# and create a new Person, this should generate the test # and create a new Person, this should generate the test
# accessor holder which should be in the Person type inheritance # accessor holder which should be in the Person type inheritance
person_type.setTypeZodbPropertySheetList('TestMigration') person_type.setTypePropertySheetList('TestMigration')
transaction.commit() transaction.commit()
self.assertTrue('TestMigration' in \ self.assertTrue('TestMigration' in person_type.getTypePropertySheetList())
person_type.getTypeZodbPropertySheetList())
# The accessor holder will be generated once the new Person will # The accessor holder will be generated once the new Person will
# be created as Person type has test Property Sheet # be created as Person type has test Property Sheet
...@@ -678,7 +674,7 @@ class TestZodbPropertySheet(ERP5TypeTestCase): ...@@ -678,7 +674,7 @@ class TestZodbPropertySheet(ERP5TypeTestCase):
# '_setType*' # '_setType*'
transaction.commit() transaction.commit()
person_type.setTypeZodbPropertySheetList(None) person_type.setTypePropertySheetList(())
if new_person is not None: if new_person is not None:
portal.person_module.deleteContent(new_person.getId()) portal.person_module.deleteContent(new_person.getId())
...@@ -689,15 +685,14 @@ class TestZodbPropertySheet(ERP5TypeTestCase): ...@@ -689,15 +685,14 @@ class TestZodbPropertySheet(ERP5TypeTestCase):
# unassigned by creating a new person in Person module # unassigned by creating a new person in Person module
transaction.commit() transaction.commit()
self.failIf('TestMigration' in \ self.failIf('TestMigration' in person_type.getTypePropertySheetList())
(person_type.getTypeZodbPropertySheetList() or []))
try: try:
new_person = portal.person_module.newContent( new_person = portal.person_module.newContent(
id='testAssignZodbPropertySheet', portal_type='Person') id='testAssignZodbPropertySheet', portal_type='Person')
self.failIfHasAttribute(new_person, 'getTestStandardPropertyAssign')
self.failIfHasAttribute(erp5.accessor_holder, 'TestMigration') self.failIfHasAttribute(erp5.accessor_holder, 'TestMigration')
self.failIfHasAttribute(new_person, 'getTestStandardPropertyAssign')
finally: finally:
if new_person is not None: if new_person is not None:
...@@ -1019,9 +1014,6 @@ class TestZodbPropertySheet(ERP5TypeTestCase): ...@@ -1019,9 +1014,6 @@ class TestZodbPropertySheet(ERP5TypeTestCase):
self.test_module.setTitle, self.test_module.setTitle,
'my_property_type_validity_constraint_title') 'my_property_type_validity_constraint_title')
TestZodbPropertySheet = skip("ZODB Property Sheets code is not enabled yet")(
TestZodbPropertySheet)
from Products.ERP5Type import PropertySheet from Products.ERP5Type import PropertySheet
from Products.CMFCore.Expression import Expression from Products.CMFCore.Expression import Expression
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment