[Erp5-report] r39408 arnaud.fontaine - in /erp5/trunk/products: ERP5/Document/ ERP5Type/Core/
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed Oct 20 23:54:11 CEST 2010
Author: arnaud.fontaine
Date: Wed Oct 20 23:54:11 2010
New Revision: 39408
URL: http://svn.erp5.org?rev=39408&view=rev
Log:
ZODB Property Sheets:
* Add CategoryProperty Document, especially relevant when the accessor
generation will be moved from Utils.
* Add Reference to property_sheets in Documents as 'reference' will be
used instead of title or id.
* Move all Documents to ERP5Type.Core as there should have always been there.
Added:
erp5/trunk/products/ERP5Type/Core/AcquiredProperty.py
- copied, changed from r39336, erp5/trunk/products/ERP5/Document/AcquiredProperty.py
erp5/trunk/products/ERP5Type/Core/CategoryProperty.py
erp5/trunk/products/ERP5Type/Core/DynamicCategoryProperty.py
- copied, changed from r39336, erp5/trunk/products/ERP5/Document/DynamicCategoryProperty.py
erp5/trunk/products/ERP5Type/Core/StandardProperty.py
- copied, changed from r39336, erp5/trunk/products/ERP5/Document/StandardProperty.py
Removed:
erp5/trunk/products/ERP5/Document/AcquiredProperty.py
erp5/trunk/products/ERP5/Document/DynamicCategoryProperty.py
erp5/trunk/products/ERP5/Document/StandardProperty.py
Removed: erp5/trunk/products/ERP5/Document/AcquiredProperty.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/AcquiredProperty.py?rev=39407&view=auto
==============================================================================
--- erp5/trunk/products/ERP5/Document/AcquiredProperty.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/AcquiredProperty.py (removed)
@@ -1,97 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2010 Nexedi SARL and Contributors. All Rights Reserved.
-# Arnaud Fontaine <arnaud.fontaine at nexedi.com>
-#
-# WARNING: This program as such is intended to be used by professional
-# programmers who take the whole responsability of assessing all potential
-# consequences resulting from its eventual inadequacies and bugs
-# End users who are looking for a ready-to-use solution with commercial
-# garantees and support are strongly adviced to contract a Free Software
-# Service Company
-#
-# This program is Free Software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-##############################################################################
-
-from AccessControl import ClassSecurityInfo
-from Products.CMFCore.Expression import Expression
-
-from Products.ERP5Type import Permissions, PropertySheet
-from Products.ERP5.Document.StandardProperty import StandardProperty
-
-class AcquiredProperty(StandardProperty):
- """
- 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'
-
- # Declarative security
- security = ClassSecurityInfo()
- security.declareObjectProtected(Permissions.AccessContentsInformation)
-
- property_sheets = StandardProperty.property_sheets + \
- (PropertySheet.AcquiredProperty,)
-
- # Filesystem-based name of attributes specific to 'content' type
- _content_type_attribute_tuple = ('portal_type',
- 'acquired_property_id',
- 'translation_acquired_property')
-
- # Add names specific to 'content' type (see StandardProperty)
- _name_mapping_filesystem_to_zodb_dict = \
- dict([ (name, 'content_' + name,) for name in _content_type_attribute_tuple ],
- **StandardProperty._name_mapping_filesystem_to_zodb_dict)
-
- # ZODB name of attributes whose value is a TALES Expression string
- _expression_attribute_tuple = \
- StandardProperty._expression_attribute_tuple + \
- ('acquisition_portal_type', 'content_portal_type')
-
- @staticmethod
- def _convertValueToTalesExpression(value):
- """
- Convert a string value to a TALES expression for attributes listed
- in '_expression_attribute_tuple'
- """
- if value is None:
- return None
-
- return Expression(value)
-
- security.declareProtected(Permissions.AccessContentsInformation,
- 'exportToFilesystemDefinition')
- def exportToFilesystemDefinition(self):
- """
- Return the filesystem definition of this ZODB property
- """
- filesystem_property_dict = \
- StandardProperty.exportToFilesystemDefinition(self)
-
- filesystem_property_dict.update(
- {'acquisition_base_category': self.getAcquisitionBaseCategoryList() or None,
- 'acquisition_object_id': self.getAcquisitionObjectIdList() or None,
- 'acquisition_portal_type': self._convertValueToTalesExpression(self.getAcquisitionPortalType()),
- 'acquisition_accessor_id': self.getAcquisitionAccessorId(),
- 'alt_accessor_id': self.getAltAccessorIdList() or None,
- 'acquisition_copy_value': self.getAcquisitionCopyValue(),
- 'acquisition_mask_value': self.getAcquisitionMaskValue(),
- 'portal_type': self._convertValueToTalesExpression(self.getContentPortalType()),
- 'acquired_property_id': self.getContentAcquiredPropertyIdList() or None,
- 'translation_acquired_property_id': self.getContentTranslationAcquiredPropertyIdList() or None})
-
- return filesystem_property_dict
Removed: erp5/trunk/products/ERP5/Document/DynamicCategoryProperty.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/DynamicCategoryProperty.py?rev=39407&view=auto
==============================================================================
--- erp5/trunk/products/ERP5/Document/DynamicCategoryProperty.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/DynamicCategoryProperty.py (removed)
@@ -1,64 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2010 Nexedi SARL and Contributors. All Rights Reserved.
-# Arnaud Fontaine <arnaud.fontaine at nexedi.com>
-#
-# WARNING: This program as such is intended to be used by professional
-# programmers who take the whole responsability of assessing all potential
-# consequences resulting from its eventual inadequacies and bugs
-# End users who are looking for a ready-to-use solution with commercial
-# garantees and support are strongly adviced to contract a Free Software
-# Service Company
-#
-# This program is Free Software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-##############################################################################
-
-from AccessControl import ClassSecurityInfo
-from Products.CMFCore.Expression import Expression
-
-from Products.ERP5Type import Permissions, PropertySheet
-from Products.ERP5Type.XMLObject import XMLObject
-
-class DynamicCategoryProperty(XMLObject):
- """
- 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)
- """
- meta_type = 'ERP5 Dynamic Category Property'
- portal_type = 'Dynamic Category Property'
-
- # Declarative security
- security = ClassSecurityInfo()
- security.declareObjectProtected(Permissions.AccessContentsInformation)
-
- property_sheets = (PropertySheet.DynamicCategoryProperty,)
-
- security.declareProtected(Permissions.AccessContentsInformation,
- 'exportToFilesystemDefinition')
- def exportToFilesystemDefinition(self):
- """
- Return the filesystem definition of the property
- """
- return Expression(self.getCategoryExpression())
-
- security.declareProtected(Permissions.AccessContentsInformation,
- 'importFromFilesystemDefinition')
- def importFromFilesystemDefinition(self, category_expression):
- """
- Set the Expression text from a filesystem definition of a property
- """
- self.setCategoryExpression(category_expression.text)
Removed: erp5/trunk/products/ERP5/Document/StandardProperty.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/StandardProperty.py?rev=39407&view=auto
==============================================================================
--- erp5/trunk/products/ERP5/Document/StandardProperty.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/StandardProperty.py (removed)
@@ -1,115 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2010 Nexedi SARL and Contributors. All Rights Reserved.
-# Arnaud Fontaine <arnaud.fontaine at nexedi.com>
-#
-# WARNING: This program as such is intended to be used by professional
-# programmers who take the whole responsability of assessing all potential
-# consequences resulting from its eventual inadequacies and bugs
-# End users who are looking for a ready-to-use solution with commercial
-# garantees and support are strongly adviced to contract a Free Software
-# Service Company
-#
-# This program is Free Software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-##############################################################################
-
-from AccessControl import ClassSecurityInfo
-from Products.CMFCore.Expression import Expression
-
-from Products.ERP5Type import Permissions, PropertySheet
-from Products.ERP5Type.XMLObject import XMLObject
-
-class StandardProperty(XMLObject):
- """
- Define an Acquired Property Document for a ZODB Property Sheet
- """
- meta_type = 'ERP5 Standard Property'
- portal_type = 'Standard Property'
-
- # Declarative security
- security = ClassSecurityInfo()
- security.declareObjectProtected(Permissions.AccessContentsInformation)
-
- property_sheets = (PropertySheet.SimpleItem,
- PropertySheet.StandardProperty,
- PropertySheet.TranslatableProperty)
-
- # 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'}
-
- # 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 ZODB property
- """
- return {'id': self.getReference(),
- 'description': self.getDescription(),
- 'type': self.getElementaryType(),
- 'storage_id': self.getStorageId(),
- 'multivalued': self.getMultivalued(),
- 'default': self.getPropertyDefault(),
- 'range': self.getRange(),
- 'preference': self.getPreference(),
- 'read_permission': self.getReadPermission(),
- 'write_permission': self.getWritePermission(),
- 'translatable': self.getTranslatable(),
- 'translation_domain': self.getTranslationDomain()}
-
- def _convertFromFilesytemPropertyDict(self, filesystem_property_dict):
- """
- Convert a property dict coming from a Property Sheet on the
- filesystem to a ZODB 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
- # value is None, or an empty tuple or string, or either 0, thus
- # skip them
- if not value:
- continue
-
- # 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 zodb_property_name in self._expression_attribute_tuple:
- value = isinstance(value, Expression) and \
- value.text or 'python: ' + repr(value)
-
- zodb_property_dict[zodb_property_name] = value
-
- return zodb_property_dict
-
- security.declareProtected(Permissions.AccessContentsInformation,
- 'importFromFilesystemDefinition')
- def importFromFilesystemDefinition(self, filesystem_property_dict):
- """
- Set attributes from the filesystem definition of a property
- """
- self.edit(**self._convertFromFilesytemPropertyDict(filesystem_property_dict))
Copied: erp5/trunk/products/ERP5Type/Core/AcquiredProperty.py (from r39336, erp5/trunk/products/ERP5/Document/AcquiredProperty.py)
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Core/AcquiredProperty.py?p2=erp5/trunk/products/ERP5Type/Core/AcquiredProperty.py&p1=erp5/trunk/products/ERP5/Document/AcquiredProperty.py&r1=39336&r2=39408&rev=39408&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/AcquiredProperty.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Core/AcquiredProperty.py [utf8] Wed Oct 20 23:54:11 2010
@@ -30,7 +30,7 @@ from AccessControl import ClassSecurityI
from Products.CMFCore.Expression import Expression
from Products.ERP5Type import Permissions, PropertySheet
-from Products.ERP5.Document.StandardProperty import StandardProperty
+from Products.ERP5Type.Core.StandardProperty import StandardProperty
class AcquiredProperty(StandardProperty):
"""
Added: erp5/trunk/products/ERP5Type/Core/CategoryProperty.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Core/CategoryProperty.py?rev=39408&view=auto
==============================================================================
--- erp5/trunk/products/ERP5Type/Core/CategoryProperty.py (added)
+++ erp5/trunk/products/ERP5Type/Core/CategoryProperty.py [utf8] Wed Oct 20 23:54:11 2010
@@ -0,0 +1,61 @@
+##############################################################################
+#
+# Copyright (c) 2010 Nexedi SARL and Contributors. All Rights Reserved.
+# Arnaud Fontaine <arnaud.fontaine at nexedi.com>
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsability of assessing all potential
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# garantees and support are strongly adviced to contract a Free Software
+# Service Company
+#
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+##############################################################################
+
+from AccessControl import ClassSecurityInfo
+from Products.ERP5Type import Permissions, PropertySheet
+from Products.ERP5Type.XMLObject import XMLObject
+
+class CategoryProperty(XMLObject):
+ """
+ Define a Category Property Document for a ZODB Property Sheets
+ """
+ meta_type = 'ERP5 Category Property'
+ portal_type = 'Category Property'
+
+ # Declarative security
+ security = ClassSecurityInfo()
+ security.declareObjectProtected(Permissions.AccessContentsInformation)
+
+ property_sheets = (PropertySheet.SimpleItem,
+ PropertySheet.Reference)
+
+ security.declareProtected(Permissions.AccessContentsInformation,
+ 'exportToFilesystemDefinition')
+ def exportToFilesystemDefinition(self):
+ """
+ Return the filesystem definition of the property
+ """
+ return self.getReference()
+
+ security.declareProtected(Permissions.AccessContentsInformation,
+ 'importFromFilesystemDefinition')
+ def importFromFilesystemDefinition(self, category_name):
+ """
+ Set the Reference from a filesystem definition of a property
+ """
+ self.setReference(category_name)
Copied: erp5/trunk/products/ERP5Type/Core/DynamicCategoryProperty.py (from r39336, erp5/trunk/products/ERP5/Document/DynamicCategoryProperty.py)
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Core/DynamicCategoryProperty.py?p2=erp5/trunk/products/ERP5Type/Core/DynamicCategoryProperty.py&p1=erp5/trunk/products/ERP5/Document/DynamicCategoryProperty.py&r1=39336&r2=39408&rev=39408&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/DynamicCategoryProperty.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Core/DynamicCategoryProperty.py [utf8] Wed Oct 20 23:54:11 2010
@@ -45,7 +45,9 @@ class DynamicCategoryProperty(XMLObject)
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
- property_sheets = (PropertySheet.DynamicCategoryProperty,)
+ property_sheets = (PropertySheet.SimpleItem,
+ PropertySheet.Reference,
+ PropertySheet.DynamicCategoryProperty)
security.declareProtected(Permissions.AccessContentsInformation,
'exportToFilesystemDefinition')
Copied: erp5/trunk/products/ERP5Type/Core/StandardProperty.py (from r39336, erp5/trunk/products/ERP5/Document/StandardProperty.py)
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Core/StandardProperty.py?p2=erp5/trunk/products/ERP5Type/Core/StandardProperty.py&p1=erp5/trunk/products/ERP5/Document/StandardProperty.py&r1=39336&r2=39408&rev=39408&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/StandardProperty.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Core/StandardProperty.py [utf8] Wed Oct 20 23:54:11 2010
@@ -44,6 +44,7 @@ class StandardProperty(XMLObject):
security.declareObjectProtected(Permissions.AccessContentsInformation)
property_sheets = (PropertySheet.SimpleItem,
+ PropertySheet.Reference,
PropertySheet.StandardProperty,
PropertySheet.TranslatableProperty)
More information about the Erp5-report
mailing list