Commit 0be09eec authored by Sebastien Robin's avatar Sebastien Robin

fixed setProperty on tempObject, now both testBase and testAmount should run fine

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@9666 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 4097fcd4
...@@ -50,6 +50,7 @@ from Acquisition import aq_base, aq_inner ...@@ -50,6 +50,7 @@ from Acquisition import aq_base, aq_inner
from zLOG import LOG from zLOG import LOG
from Products.ERP5Type.DateUtils import addToDate from Products.ERP5Type.DateUtils import addToDate
from Products.ERP5Type.tests.Sequence import Sequence, SequenceList from Products.ERP5Type.tests.Sequence import Sequence, SequenceList
from zExceptions import BadRequest
import time import time
import os import os
from Products.ERP5Type import product_path from Products.ERP5Type import product_path
...@@ -68,7 +69,7 @@ class TestBase(ERP5TypeTestCase): ...@@ -68,7 +69,7 @@ class TestBase(ERP5TypeTestCase):
temp_class = "Amount" temp_class = "Amount"
defined_property_id = "title" defined_property_id = "title"
defined_property_value = "a_wonderful_title" defined_property_value = "a_wonderful_title"
not_related_to_temp_object_property_id = "int_index" not_related_to_temp_object_property_id = "string_index"
not_related_to_temp_object_property_value = "a_great_index" not_related_to_temp_object_property_value = "a_great_index"
def getTitle(self): def getTitle(self):
...@@ -743,7 +744,7 @@ class TestBase(ERP5TypeTestCase): ...@@ -743,7 +744,7 @@ class TestBase(ERP5TypeTestCase):
object_instance.getProperty( object_instance.getProperty(
self.not_related_to_temp_object_property_id)) self.not_related_to_temp_object_property_id))
def test_06_getPropertyOnTempClass(self, quiet=quiet, run=run_all_test): def test_06_getPropertyOnTempClass(self, quiet=quiet, run=1):
""" """
Test if set/getProperty work in temp object without Test if set/getProperty work in temp object without
a portal type with the same name. a portal type with the same name.
...@@ -773,12 +774,10 @@ class TestBase(ERP5TypeTestCase): ...@@ -773,12 +774,10 @@ class TestBase(ERP5TypeTestCase):
Check if edit method works. Check if edit method works.
""" """
object_instance = sequence.get('object_instance') object_instance = sequence.get('object_instance')
old_edit_method = sequence.get('edit_method') object_instance.edit(title='toto')
edit_method = object_instance.edit self.assertEquals(object_instance.getTitle(),'toto')
if old_edit_method is None: object_instance.edit(title='tutu')
sequence.edit(edit_method=edit_method) self.assertEquals(object_instance.getTitle(),'tutu')
else:
self.assertEquals(old_edit_method, edit_method)
def stepSetEditProperty(self, sequence=None, def stepSetEditProperty(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
...@@ -786,7 +785,8 @@ class TestBase(ERP5TypeTestCase): ...@@ -786,7 +785,8 @@ class TestBase(ERP5TypeTestCase):
Check if edit method works. Check if edit method works.
""" """
object_instance = sequence.get('object_instance') object_instance = sequence.get('object_instance')
object_instance.setProperty('edit', "now this object is 'read only !!!'") self.assertRaises(BadRequest,object_instance.setProperty, 'edit',
"now this object is 'read only !!!'")
def test_07_setEditProperty(self, quiet=quiet, run=run_all_test): def test_07_setEditProperty(self, quiet=quiet, run=run_all_test):
""" """
......
...@@ -878,9 +878,12 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ): ...@@ -878,9 +878,12 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ):
ERP5PropertyManager._setProperty(self, key, value, type=type) ERP5PropertyManager._setProperty(self, key, value, type=type)
except ConflictError: except ConflictError:
raise raise
except: # This should not be there, because this ignore all checks made by
# This should be removed if we want strict property checking # the PropertyManager. If there is problems, please complain to
setattr(self, key, value) # seb@nexedi.com
#except:
# # This should be removed if we want strict property checking
# setattr(self, key, value)
def _setPropValue(self, key, value, **kw): def _setPropValue(self, key, value, **kw):
#LOG('_setPropValue', 0, 'self = %r, key = %r, value = %r, kw = %r' % (self, key, value, kw)) #LOG('_setPropValue', 0, 'self = %r, key = %r, value = %r, kw = %r' % (self, key, value, kw))
......
...@@ -20,6 +20,7 @@ from Products.ERP5Type.Utils import createExpressionContext ...@@ -20,6 +20,7 @@ from Products.ERP5Type.Utils import createExpressionContext
from Products.ERP5Type.ERP5Type import ERP5TypeInformation from Products.ERP5Type.ERP5Type import ERP5TypeInformation
from Products.CMFCore.Expression import Expression from Products.CMFCore.Expression import Expression
from Products.ERP5Type import _dtmldir from Products.ERP5Type import _dtmldir
from Acquisition import aq_base
from zExceptions import BadRequest from zExceptions import BadRequest
class ERP5PropertyManager(PropertyManager): class ERP5PropertyManager(PropertyManager):
...@@ -116,6 +117,18 @@ def PropertyManager_setProperty(self, id, value, type=None): ...@@ -116,6 +117,18 @@ def PropertyManager_setProperty(self, id, value, type=None):
'_local_properties', ()) + ({'id':id, 'type':type},) '_local_properties', ()) + ({'id':id, 'type':type},)
self._setPropValue(id, value) self._setPropValue(id, value)
def PropertyManager_valid_property_id(self, id):
# This is required because in order to disable acquisition
# we set all properties with a None value on the class Base,
# so wee need to check if the property is not on Base.__dict__
from Products.ERP5Type.Base import Base
if not id or id[:1]=='_' or (id[:3]=='aq_') \
or (' ' in id) or (hasattr(aq_base(self), id) and \
not (Base.__dict__.has_key(id) and Base.__dict__[id] is None)) or escape(id) != id:
return 0
return 1
def PropertyManager_delProperty(self, id): def PropertyManager_delProperty(self, id):
if not self.hasProperty(id): if not self.hasProperty(id):
raise ValueError, 'The property %s does not exist' % escape(id) raise ValueError, 'The property %s does not exist' % escape(id)
...@@ -168,6 +181,7 @@ def PropertyManager_manage_addProperty(self, id, value, type, REQUEST=None): ...@@ -168,6 +181,7 @@ def PropertyManager_manage_addProperty(self, id, value, type, REQUEST=None):
PropertyManager.manage_addProperty = PropertyManager_manage_addProperty PropertyManager.manage_addProperty = PropertyManager_manage_addProperty
PropertyManager.manage_propertiesForm = PropertyManager_manage_propertiesForm PropertyManager.manage_propertiesForm = PropertyManager_manage_propertiesForm
PropertyManager._updateProperty = PropertyManager_updateProperty PropertyManager._updateProperty = PropertyManager_updateProperty
PropertyManager.valid_property_id = PropertyManager_valid_property_id
PropertyManager.getPropertyType = PropertyManager_getPropertyType PropertyManager.getPropertyType = PropertyManager_getPropertyType
PropertyManager._setProperty = PropertyManager_setProperty PropertyManager._setProperty = PropertyManager_setProperty
PropertyManager._delProperty = PropertyManager_delProperty PropertyManager._delProperty = PropertyManager_delProperty
......
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