[Erp5-report] r38999 arnaud.fontaine - /erp5/trunk/products/ERP5/Document/
nobody at svn.erp5.org
nobody at svn.erp5.org
Fri Oct 8 13:19:11 CEST 2010
Author: arnaud.fontaine
Date: Fri Oct 8 13:19:10 2010
New Revision: 38999
URL: http://svn.erp5.org?rev=38999&view=rev
Log:
Convert 'default' attribute to a TALES expression for web-based Property Sheets
Modified:
erp5/trunk/products/ERP5/Document/AcquiredProperty.py
erp5/trunk/products/ERP5/Document/StandardProperty.py
Modified: erp5/trunk/products/ERP5/Document/AcquiredProperty.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/AcquiredProperty.py?rev=38999&r1=38998&r2=38999&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/AcquiredProperty.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/AcquiredProperty.py [utf8] Fri Oct 8 13:19:10 2010
@@ -59,8 +59,10 @@ class AcquiredProperty(StandardProperty)
**StandardProperty._name_mapping_filesystem_to_web_dict)
# Web-based name of attributes whose value is a TALES Expression
- _expression_attribute_tuple = ('acquisition_portal_type',
- 'content_portal_type')
+ # string
+ _expression_attribute_tuple = \
+ StandardProperty._expression_attribute_tuple + \
+ ('acquisition_portal_type', 'content_portal_type')
@staticmethod
def _convertValueToTalesExpression(value):
@@ -68,7 +70,10 @@ class AcquiredProperty(StandardProperty)
Convert a string value to a TALES expression for attributes listed
in '_expression_attribute_tuple'
"""
- return value is None and value or Expression(value)
+ if value is None:
+ return None
+
+ return Expression(value)
security.declareProtected(Permissions.AccessContentsInformation,
'exportToFilesystemDefinition')
@@ -92,22 +97,3 @@ class AcquiredProperty(StandardProperty)
'translation_acquired_property_id': self.getContentTranslationAcquiredPropertyIdList() or None})
return filesystem_property_dict
-
- def _convertFromFilesytemPropertyDict(self, filesystem_property_dict):
- """
- Convert a property dict coming from a Property Sheet on the
- filesystem to a web-based property dict
- """
- web_property_dict = StandardProperty._convertFromFilesytemPropertyDict(
- self, filesystem_property_dict)
-
- # Update the properties whose values are TALES Expression
- for attribute in self._expression_attribute_tuple:
- if attribute in web_property_dict:
- value = isinstance(web_property_dict[attribute], Expression) and \
- web_property_dict[attribute].text or \
- 'python: ' + repr(web_property_dict[attribute])
-
- web_property_dict[attribute] = value
-
- return web_property_dict
Modified: erp5/trunk/products/ERP5/Document/StandardProperty.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/StandardProperty.py?rev=38999&r1=38998&r2=38999&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/StandardProperty.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/StandardProperty.py [utf8] Fri Oct 8 13:19:10 2010
@@ -27,6 +27,7 @@
##############################################################################
from AccessControl import ClassSecurityInfo
+from Products.CMFCore.Expression import Expression
from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5Type.XMLObject import XMLObject
@@ -53,6 +54,10 @@ class StandardProperty(XMLObject):
'type': 'elementary_type',
'default': 'property_default'}
+ # Web-based name of attributes whose value is a TALES Expression
+ # string
+ _expression_attribute_tuple = ('property_default',)
+
security.declareProtected(Permissions.AccessContentsInformation,
'exportToFilesystemDefinition')
def exportToFilesystemDefinition(self):
@@ -81,12 +86,24 @@ class StandardProperty(XMLObject):
web_property_dict = {}
for fs_property_name, value in filesystem_property_dict.iteritems():
+ # Property Sheets on the filesystem defined attributes whose
+ # value is None, or an empty tuple or string, or either 0, thus
+ # skip them
+ 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 \
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:
+ value = isinstance(value, Expression) and \
+ value.text or 'python: ' + repr(value)
+
web_property_dict[web_property_name] = value
return web_property_dict
More information about the Erp5-report
mailing list