Commit d6a5d3e3 authored by Romain Courteaud's avatar Romain Courteaud

Try to guess the type of a newly created local property.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@21382 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 84ba1a9f
......@@ -61,6 +61,7 @@ from Products.ERP5Type.Cache import CachingMethod, clearCache, getReadOnlyTransa
from Accessor import WorkflowState
from Products.ERP5Type.Log import log as unrestrictedLog
from Products.ERP5Type.TransactionalVariable import getTransactionalVariable
from Products.ERP5Type.Accessor.TypeDefinition import type_definition
from ZopePatch import ERP5PropertyManager
from CopySupport import CopyContainer, CopyError,\
......@@ -1426,7 +1427,15 @@ class Base( CopyContainer,
if ERP5PropertyManager.hasProperty(self,key):
ERP5PropertyManager._updateProperty(self, key, value)
else:
ERP5PropertyManager._setProperty(self, key, value, type=type)
# Try to guess the type definition of this non defined property
for type_name, type_dict in type_definition.items():
# XXX type parameter name is bad, because it's a builtin function of
# python
if isinstance(value, __builtins__['type'](type_dict.get('default'))):
type = type_name
break
ERP5PropertyManager._setProperty(self, key, value,
type=type)
# This should not be there, because this ignore all checks made by
# the PropertyManager. If there is problems, please complain to
# seb@nexedi.com
......
......@@ -516,7 +516,7 @@ class TestConstraint(PropertySheetTestCase):
SetObjectBadTypedProperty \
CreatePropertyTypeValidity \
CallCheckConsistency \
CheckIfConstraintFailed \
CheckIfConstraintSucceeded \
'
sequence_list.addSequenceString(sequence_string)
# Test Constraint with property defined on object
......@@ -536,7 +536,7 @@ class TestConstraint(PropertySheetTestCase):
SetObjectBadTypedProperty \
CreatePropertyTypeValidity \
CallFixConsistency \
CheckIfConstraintFailed \
CheckIfConstraintSucceeded \
CallCheckConsistency \
CheckIfConstraintSucceeded \
'
......@@ -550,7 +550,7 @@ class TestConstraint(PropertySheetTestCase):
SetObjectIntLocalProperty \
CreatePropertyTypeValidity \
CallFixConsistency \
CheckIfConstraintFailed \
CheckIfConstraintSucceeded \
CallCheckConsistency \
CheckIfConstraintSucceeded \
'
......@@ -1429,8 +1429,7 @@ class TestConstraint(PropertySheetTestCase):
message = consistency_message_list[0]
self.assertEquals('Attribute title does not match',
str(message.getTranslatedMessage()))
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestConstraint))
......
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