Commit 5ce748e6 authored by Arnaud Fontaine's avatar Arnaud Fontaine

Use zodb instead of web for new-style Property Sheets

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@39002 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c82cf280
...@@ -34,9 +34,8 @@ from Products.ERP5.Document.StandardProperty import StandardProperty ...@@ -34,9 +34,8 @@ from Products.ERP5.Document.StandardProperty import StandardProperty
class AcquiredProperty(StandardProperty): class AcquiredProperty(StandardProperty):
""" """
Define an Acquired Property Document for a web-based Property Sheet Define an Acquired Property Document for a ZODB Property Sheet (an
(an Acquired Property only brings new attributes to a Standard Acquired Property only brings new attributes to a Standard Property)
Property)
""" """
meta_type = 'ERP5 Acquired Property' meta_type = 'ERP5 Acquired Property'
portal_type = 'Acquired Property' portal_type = 'Acquired Property'
...@@ -54,12 +53,11 @@ class AcquiredProperty(StandardProperty): ...@@ -54,12 +53,11 @@ class AcquiredProperty(StandardProperty):
'translation_acquired_property') 'translation_acquired_property')
# Add names specific to 'content' type (see StandardProperty) # Add names specific to 'content' type (see StandardProperty)
_name_mapping_filesystem_to_web_dict = \ _name_mapping_filesystem_to_zodb_dict = \
dict([ (name, 'content_' + name,) for name in _content_type_attribute_tuple ], dict([ (name, 'content_' + name,) for name in _content_type_attribute_tuple ],
**StandardProperty._name_mapping_filesystem_to_web_dict) **StandardProperty._name_mapping_filesystem_to_zodb_dict)
# Web-based name of attributes whose value is a TALES Expression # ZODB name of attributes whose value is a TALES Expression string
# string
_expression_attribute_tuple = \ _expression_attribute_tuple = \
StandardProperty._expression_attribute_tuple + \ StandardProperty._expression_attribute_tuple + \
('acquisition_portal_type', 'content_portal_type') ('acquisition_portal_type', 'content_portal_type')
...@@ -79,7 +77,7 @@ class AcquiredProperty(StandardProperty): ...@@ -79,7 +77,7 @@ class AcquiredProperty(StandardProperty):
'exportToFilesystemDefinition') 'exportToFilesystemDefinition')
def exportToFilesystemDefinition(self): def exportToFilesystemDefinition(self):
""" """
Return the filesystem definition of this web-based property Return the filesystem definition of this ZODB property
""" """
filesystem_property_dict = \ filesystem_property_dict = \
StandardProperty.exportToFilesystemDefinition(self) StandardProperty.exportToFilesystemDefinition(self)
......
...@@ -34,7 +34,7 @@ from Products.ERP5Type.XMLObject import XMLObject ...@@ -34,7 +34,7 @@ from Products.ERP5Type.XMLObject import XMLObject
class DynamicCategoryProperty(XMLObject): class DynamicCategoryProperty(XMLObject):
""" """
Define a Dynamic Category Property Document for a web-based Property Define a Dynamic Category Property Document for a ZODB Property
Sheets (a dynamic category is defined by a TALES expression rather Sheets (a dynamic category is defined by a TALES expression rather
than a string and is being used by Item and Movement for example) than a string and is being used by Item and Movement for example)
""" """
......
...@@ -34,7 +34,7 @@ from Products.ERP5Type.XMLObject import XMLObject ...@@ -34,7 +34,7 @@ from Products.ERP5Type.XMLObject import XMLObject
class StandardProperty(XMLObject): class StandardProperty(XMLObject):
""" """
Define an Acquired Property Document for a web-based Property Sheet Define an Acquired Property Document for a ZODB Property Sheet
""" """
meta_type = 'ERP5 Standard Property' meta_type = 'ERP5 Standard Property'
portal_type = 'Standard Property' portal_type = 'Standard Property'
...@@ -47,22 +47,20 @@ class StandardProperty(XMLObject): ...@@ -47,22 +47,20 @@ class StandardProperty(XMLObject):
PropertySheet.StandardProperty, PropertySheet.StandardProperty,
PropertySheet.TranslatableProperty) PropertySheet.TranslatableProperty)
# Names mapping between filesystem to web-based property, only # Names mapping between filesystem to ZODB property, only meaningful
# meaningful when importing a property from its filesystem # when importing a property from its filesystem definition
# definition _name_mapping_filesystem_to_zodb_dict = {'id': 'reference',
_name_mapping_filesystem_to_web_dict = {'id': 'reference',
'type': 'elementary_type', 'type': 'elementary_type',
'default': 'property_default'} 'default': 'property_default'}
# Web-based name of attributes whose value is a TALES Expression # ZODB name of attributes whose value is a TALES Expression string
# string
_expression_attribute_tuple = ('property_default',) _expression_attribute_tuple = ('property_default',)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'exportToFilesystemDefinition') 'exportToFilesystemDefinition')
def exportToFilesystemDefinition(self): def exportToFilesystemDefinition(self):
""" """
Return the filesystem definition of this web-based property Return the filesystem definition of this ZODB property
""" """
return {'id': self.getReference(), return {'id': self.getReference(),
'description': self.getDescription(), 'description': self.getDescription(),
...@@ -80,10 +78,10 @@ class StandardProperty(XMLObject): ...@@ -80,10 +78,10 @@ class StandardProperty(XMLObject):
def _convertFromFilesytemPropertyDict(self, filesystem_property_dict): def _convertFromFilesytemPropertyDict(self, filesystem_property_dict):
""" """
Convert a property dict coming from a Property Sheet on the Convert a property dict coming from a Property Sheet on the
filesystem to a web-based property dict filesystem to a ZODB property dict
""" """
# Prepare a dictionnary of the web-based property # Prepare a dictionnary of the ZODB property
web_property_dict = {} zodb_property_dict = {}
for fs_property_name, value in filesystem_property_dict.iteritems(): for fs_property_name, value in filesystem_property_dict.iteritems():
# Property Sheets on the filesystem defined attributes whose # Property Sheets on the filesystem defined attributes whose
...@@ -92,21 +90,21 @@ class StandardProperty(XMLObject): ...@@ -92,21 +90,21 @@ class StandardProperty(XMLObject):
if not value: if not value:
continue continue
# Convert filesystem property name to web-based if necessary # Convert filesystem property name to ZODB if necessary
web_property_name = \ zodb_property_name = \
fs_property_name in self._name_mapping_filesystem_to_web_dict and \ fs_property_name in self._name_mapping_filesystem_to_zodb_dict and \
self._name_mapping_filesystem_to_web_dict[fs_property_name] or \ self._name_mapping_filesystem_to_zodb_dict[fs_property_name] or \
fs_property_name fs_property_name
# Convert existing TALES expression class or primitive type to a # Convert existing TALES expression class or primitive type to a
# TALES expression string # TALES expression string
if web_property_name in self._expression_attribute_tuple: if zodb_property_name in self._expression_attribute_tuple:
value = isinstance(value, Expression) and \ value = isinstance(value, Expression) and \
value.text or 'python: ' + repr(value) value.text or 'python: ' + repr(value)
web_property_dict[web_property_name] = value zodb_property_dict[zodb_property_name] = value
return web_property_dict return zodb_property_dict
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'importFromFilesystemDefinition') 'importFromFilesystemDefinition')
......
...@@ -137,7 +137,7 @@ def portal_type_factory(portal_type_name): ...@@ -137,7 +137,7 @@ def portal_type_factory(portal_type_name):
# Initialize Property Sheets accessor holders # Initialize Property Sheets accessor holders
import erp5.accessor_holder import erp5.accessor_holder
# Get the web-based Property Sheets for this Portal Type # Get the ZODB Property Sheets for this Portal Type
property_sheet_name_set = set( property_sheet_name_set = set(
portal_type.getNewStyleTypePropertySheetList() or []) portal_type.getNewStyleTypePropertySheetList() or [])
...@@ -194,7 +194,7 @@ def initializeDynamicModules(): ...@@ -194,7 +194,7 @@ def initializeDynamicModules():
for example classes created through ClassTool that are in for example classes created through ClassTool that are in
$INSTANCE_HOME/Document $INSTANCE_HOME/Document
erp5.accessor_holder erp5.accessor_holder
holds accessors of web-based Property Sheet holds accessors of ZODB Property Sheet
""" """
def portal_type_loader(portal_type_name): def portal_type_loader(portal_type_name):
""" """
...@@ -290,7 +290,7 @@ def synchronizeDynamicModules(context, force=False): ...@@ -290,7 +290,7 @@ def synchronizeDynamicModules(context, force=False):
klass.__bases__ = ghostbase klass.__bases__ = ghostbase
type(ExtensionBase).__init__(klass, klass) type(ExtensionBase).__init__(klass, klass)
# Clear accessor holders of web-based Property Sheets # Clear accessor holders of ZODB Property Sheets
for accessor_name in erp5.accessor_holder.__dict__.keys(): for accessor_name in erp5.accessor_holder.__dict__.keys():
if not accessor_name.startswith('__'): if not accessor_name.startswith('__'):
delattr(erp5.accessor_holder, accessor_name) delattr(erp5.accessor_holder, accessor_name)
...@@ -148,8 +148,8 @@ class PropertySheetTool(BaseTool): ...@@ -148,8 +148,8 @@ class PropertySheetTool(BaseTool):
'exportPropertySheetToFilesystemDefinitionTuple') 'exportPropertySheetToFilesystemDefinitionTuple')
def exportPropertySheetToFilesystemDefinitionTuple(self, property_sheet): def exportPropertySheetToFilesystemDefinitionTuple(self, property_sheet):
""" """
Export a given web-based Property Sheet to its filesystem Export a given ZODB Property Sheet to its filesystem definition as
definition as tuple (properties, categories, constraints) tuple (properties, categories, constraints)
XXX: Implement constraints XXX: Implement constraints
""" """
......
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