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