Commit b1dfa013 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

store recorded properties in another PersistentMapping.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@30642 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent bea8ef22
...@@ -118,7 +118,6 @@ class SimulationMovement(Movement, PropertyRecordableMixin): ...@@ -118,7 +118,6 @@ class SimulationMovement(Movement, PropertyRecordableMixin):
, PropertySheet.AppliedRule , PropertySheet.AppliedRule
, PropertySheet.ItemAggregation , PropertySheet.ItemAggregation
, PropertySheet.Reference , PropertySheet.Reference
, PropertySheet.PropertyRecordable
) )
def tpValues(self) : def tpValues(self) :
......
#############################################################################
#
# 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'
},
)
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
import zope.interface import zope.interface
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, interfaces from Products.ERP5Type import Permissions, interfaces
from Products.ERP5Type.Globals import PersistentMapping
class PropertyRecordableMixin: class PropertyRecordableMixin:
""" """
...@@ -58,7 +59,7 @@ class PropertyRecordableMixin: ...@@ -58,7 +59,7 @@ class PropertyRecordableMixin:
id -- ID of the property id -- ID of the property
""" """
recorded_property_dict = self.getRecordedPropertyDict({}) recorded_property_dict = self._getRecordedPropertyDict()
# XXX it is better to use getPropertyList only for list type # XXX it is better to use getPropertyList only for list type
# properties or categories. # properties or categories.
recorded_property_dict[id] = self.getPropertyList(id) recorded_property_dict[id] = self.getPropertyList(id)
...@@ -71,7 +72,7 @@ class PropertyRecordableMixin: ...@@ -71,7 +72,7 @@ class PropertyRecordableMixin:
Clears a previously recorded property from Clears a previously recorded property from
the property record. the property record.
""" """
recorded_property_dict = self.getRecordedPropertyDict({}) recorded_property_dict = self._getRecordedPropertyDict()
try: try:
del(recorded_property_dict[id]) del(recorded_property_dict[id])
except KeyError: except KeyError:
...@@ -86,7 +87,7 @@ class PropertyRecordableMixin: ...@@ -86,7 +87,7 @@ class PropertyRecordableMixin:
Returns the list of property IDs which have Returns the list of property IDs which have
been recorded. been recorded.
""" """
return (self.getRecordedPropertyDict({}).keys()) return (self._getRecordedPropertyDict().keys())
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'isPropertyRecorded') 'isPropertyRecorded')
...@@ -97,7 +98,7 @@ class PropertyRecordableMixin: ...@@ -97,7 +98,7 @@ class PropertyRecordableMixin:
id -- ID of the property id -- ID of the property
""" """
return self.getRecordedPropertyDict({}).has_key(id) return self._getRecordedPropertyDict().has_key(id)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getRecordedProperty') 'getRecordedProperty')
...@@ -107,7 +108,7 @@ class PropertyRecordableMixin: ...@@ -107,7 +108,7 @@ class PropertyRecordableMixin:
id -- ID of the property id -- ID of the property
""" """
return self.getRecordedPropertyDict({})[id] return self._getRecordedPropertyDict()[id]
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'asRecordedContext') 'asRecordedContext')
...@@ -117,5 +118,10 @@ class PropertyRecordableMixin: ...@@ -117,5 +118,10 @@ class PropertyRecordableMixin:
which recorded properties in its context. which recorded properties in its context.
""" """
context = self.asContext() context = self.asContext()
context.edit(**self.getRecordedPropertyDict({})) context.edit(**self._getRecordedPropertyDict())
return context return context
def self._getRecordedPropertyDict(self):
if getattr(aq_base(self), '_recorded_property_dict', None) is None:
self._recorded_property_dict = PersistentMapping()
return self._recorded_property_dict
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