Commit 6c334df1 authored by Jean-Paul Smets's avatar Jean-Paul Smets

Added support for keep_default

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@10006 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 430397aa
...@@ -30,9 +30,9 @@ from Base import func_code, type_definition, list_types, ATTRIBUTE_PREFIX, Metho ...@@ -30,9 +30,9 @@ from Base import func_code, type_definition, list_types, ATTRIBUTE_PREFIX, Metho
from zLOG import LOG from zLOG import LOG
from Products.ERP5Type.PsycoWrapper import psyco from Products.ERP5Type.PsycoWrapper import psyco
class Setter(Method): class SetSetter(Method):
""" """
Sets a reference Sets a category value through a provided value (List mode)
""" """
_need__name__=1 _need__name__=1
...@@ -51,14 +51,31 @@ class Setter(Method): ...@@ -51,14 +51,31 @@ class Setter(Method):
instance._setValue(self._key, args[0], instance._setValue(self._key, args[0],
spec=kw.get('spec',()), spec=kw.get('spec',()),
filter=kw.get('filter', None), filter=kw.get('filter', None),
portal_type=kw.get('portal_type',())) portal_type=kw.get('portal_type',()),
keep_default=1)
if self._reindex: instance.reindexObject()
psyco.bind(__call__)
class ListSetter(SetSetter):
"""
Sets a category value through a provided value (Set mode)
"""
_need__name__=1
def __call__(self, instance, *args, **kw):
if self._warning:
LOG("ERP5Type Deprecated Getter Id:",0, self._id)
instance._setValue(self._key, args[0],
spec=kw.get('spec',()),
filter=kw.get('filter', None),
portal_type=kw.get('portal_type',()),
keep_default=0)
if self._reindex: instance.reindexObject() if self._reindex: instance.reindexObject()
psyco.bind(__call__) psyco.bind(__call__)
ListSetter = Setter DefaultSetter = SetSetter
SetSetter = Setter # Error XXX
DefaultSetter = Setter # Error XXX
class DefaultGetter(Method): class DefaultGetter(Method):
""" """
...@@ -146,10 +163,7 @@ class DefaultTitleGetter(Method): ...@@ -146,10 +163,7 @@ class DefaultTitleGetter(Method):
self._key = key self._key = key
def __call__(self, instance, *args, **kw): def __call__(self, instance, *args, **kw):
o = instance._getDefaultAcquiredValue(self._key, o = instance._getDefaultAcquiredValue(self._key, **kw)
spec=kw.get('spec',()),
filter=kw.get('filter', None),
portal_type=kw.get('portal_type',()))
if o is None: if o is None:
return None return None
return o.getTitle() return o.getTitle()
...@@ -175,11 +189,7 @@ class TitleListGetter(Method): ...@@ -175,11 +189,7 @@ class TitleListGetter(Method):
self._key = key self._key = key
def __call__(self, instance, *args, **kw): def __call__(self, instance, *args, **kw):
return [x.getTitle() for x in instance._getAcquiredValueList(self._key, return [x.getTitle() for x in instance._getAcquiredValueList(self._key, **kw)]
spec=kw.get('spec',()),
filter=kw.get('filter', None),
portal_type=kw.get('portal_type',()))
]
psyco.bind(__call__) psyco.bind(__call__)
......
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