[Erp5-report] r30474 - in /erp5/trunk/products/ERP5: Document/ PropertySheet/ mixin/
nobody at svn.erp5.org
nobody at svn.erp5.org
Tue Nov 10 15:24:00 CET 2009
Author: kazuhiko
Date: Tue Nov 10 15:23:56 2009
New Revision: 30474
URL: http://svn.erp5.org?rev=30474&view=rev
Log:
* add PropertyRecordable property sheet.
* add PropertyRecordableMixin.
* use them in Simulation Movement.
Added:
erp5/trunk/products/ERP5/PropertySheet/PropertyRecordable.py
erp5/trunk/products/ERP5/mixin/property_recordable.py
Modified:
erp5/trunk/products/ERP5/Document/SimulationMovement.py
Modified: erp5/trunk/products/ERP5/Document/SimulationMovement.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/SimulationMovement.py?rev=30474&r1=30473&r2=30474&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/SimulationMovement.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/SimulationMovement.py [utf8] Tue Nov 10 15:23:56 2009
@@ -43,6 +43,7 @@
from Products.ERP5.Document.AppliedRule import TREE_DELIVERED_CACHE_KEY, TREE_DELIVERED_CACHE_ENABLED
from Products.ERP5Type.patches.WorkflowTool import WorkflowHistoryList
+from Products.ERP5.mixin.property_recordable import PropertyRecordableMixin
# XXX Do we need to create groups ? (ie. confirm group include confirmed, getting_ready and ready
@@ -61,7 +62,7 @@
'invoiced' : 'planned',
}
-class SimulationMovement(Movement):
+class SimulationMovement(Movement, PropertyRecordableMixin):
"""
Simulation movements belong to a simulation workflow which includes
the following steps
@@ -102,9 +103,6 @@
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
-
- # Declarative interfaces
- zope.interface.implements(interfaces.IPropertyRecordable,)
# Declarative properties
property_sheets = ( PropertySheet.Base
@@ -120,6 +118,7 @@
, PropertySheet.AppliedRule
, PropertySheet.ItemAggregation
, PropertySheet.Reference
+ , PropertySheet.PropertyRecordable
)
def tpValues(self) :
Added: erp5/trunk/products/ERP5/PropertySheet/PropertyRecordable.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/PropertySheet/PropertyRecordable.py?rev=30474&view=auto
==============================================================================
--- erp5/trunk/products/ERP5/PropertySheet/PropertyRecordable.py (added)
+++ erp5/trunk/products/ERP5/PropertySheet/PropertyRecordable.py [utf8] Tue Nov 10 15:23:56 2009
@@ -1,0 +1,39 @@
+#############################################################################
+#
+# Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved.
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsibility 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
+# guarantees 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+##############################################################################
+
+class PropertyRecordable:
+ """
+ Properties for property recordable documents
+ """
+
+ _properties = (
+ {'id' :'recorded_property_dict',
+ 'description':'The dict of recorded properties.',
+ 'type' :'data',
+ 'mode' :'w'
+ },
+ )
Added: erp5/trunk/products/ERP5/mixin/property_recordable.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/mixin/property_recordable.py?rev=30474&view=auto
==============================================================================
--- erp5/trunk/products/ERP5/mixin/property_recordable.py (added)
+++ erp5/trunk/products/ERP5/mixin/property_recordable.py [utf8] Tue Nov 10 15:23:56 2009
@@ -1,0 +1,121 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved.
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsibility 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
+# guarantees 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+##############################################################################
+
+import zope.interface
+from AccessControl import ClassSecurityInfo
+from Products.ERP5Type import Permissions, interfaces
+
+class PropertyRecordableMixin:
+ """
+ This class provides a generic implementation of IPropertyRecordable.
+
+ IPropertyRecordable provides methods to record
+ existing properties of a document and later retrieve
+ them. It is used by simulation to record forced
+ properties on simulation movements, but could be used
+ for other purpose.
+
+ TODO:
+ - extend interface to support time (getRecordedPropertyList)
+ """
+
+ # Declarative security
+ security = ClassSecurityInfo()
+ security.declareObjectProtected(Permissions.AccessContentsInformation)
+
+ # Declarative interfaces
+ zope.interface.implements(interfaces.IPropertyRecordable,)
+
+ security.declareProtected(Permissions.ModifyPortalContent, 'recordProperty')
+ def recordProperty(self, id):
+ """
+ Records the current value of a property.
+
+ id -- ID of the property
+ """
+ recorded_property_dict = self.getRecordedPropertyDict({})
+ # XXX it is better to use getPropertyList only for list type
+ # properties or categories.
+ recorded_property_dict[id] = self.getPropertyList(id)
+ self.setRecordedPropertyDict(recorded_property_dict)
+
+ security.declareProtected(Permissions.ModifyPortalContent,
+ 'clearRecordedProperty')
+ def clearRecordedProperty(self, id):
+ """
+ Clears a previously recorded property from
+ the property record.
+ """
+ recorded_property_dict = self.getRecordedPropertyDict({})
+ try:
+ del(recorded_property_dict[id])
+ except KeyError:
+ pass
+ else:
+ self.setRecordedPropertyDict(recorded_property_dict)
+
+ security.declareProtected(Permissions.AccessContentsInformation,
+ 'getRecordedPropertyIdList')
+ def getRecordedPropertyIdList(self):
+ """
+ Returns the list of property IDs which have
+ been recorded.
+ """
+ return (self.getRecordedPropertyDict({}).keys())
+
+ security.declareProtected(Permissions.AccessContentsInformation,
+ 'isPropertyRecorded')
+ def isPropertyRecorded(self, id):
+ """
+ Returns True if property with given ID has been
+ previously recorded, False else.
+
+ id -- ID of the property
+ """
+ return self.getRecordedPropertyDict({}).has_key(id)
+
+ security.declareProtected(Permissions.AccessContentsInformation,
+ 'getRecordedProperty')
+ def getRecordedProperty(self, id):
+ """
+ Returns recorded value of property with given ID
+
+ id -- ID of the property
+ """
+ return self.getRecordedPropertyDict({})[id]
+
+ security.declareProtected(Permissions.AccessContentsInformation,
+ 'asRecordedContext')
+ def asRecordedContext(self):
+ """
+ Returns current document as a temp document
+ which recorded properties in its context.
+ """
+ context = self.asContext()
+ context.edit(**self.getRecordedPropertyDict({}))
+ return context
More information about the Erp5-report
mailing list