Commit 79470cfd authored by Jean-Paul Smets's avatar Jean-Paul Smets

multiple bugfixes after initial implementation


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@1172 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent fb0f1359
...@@ -37,8 +37,8 @@ class Getter(Method): ...@@ -37,8 +37,8 @@ class Getter(Method):
# Generic Definition of Method Object # Generic Definition of Method Object
# This is required to call the method form the Web # This is required to call the method form the Web
func_code = func_code() func_code = func_code()
func_code.co_varnames = ('self',) func_code.co_varnames = ('self', 'instance', 'args', 'kw')
func_code.co_argcount = 1 func_code.co_argcount = 2
func_defaults = () func_defaults = ()
def __init__(self, id, key, property_type, portal_type, acquired_property, def __init__(self, id, key, property_type, portal_type, acquired_property,
...@@ -102,8 +102,8 @@ class Setter(Method): ...@@ -102,8 +102,8 @@ class Setter(Method):
# Generic Definition of Method Object # Generic Definition of Method Object
# This is required to call the method form the Web # This is required to call the method form the Web
func_code = func_code() func_code = func_code()
func_code.co_varnames = ('self',) func_code.co_varnames = ('self', 'instance', 'args', 'kw')
func_code.co_argcount = 1 func_code.co_argcount = 2
func_defaults = () func_defaults = ()
def __init__(self, id, key, property_type, portal_type, acquired_property, def __init__(self, id, key, property_type, portal_type, acquired_property,
...@@ -139,7 +139,7 @@ class Setter(Method): ...@@ -139,7 +139,7 @@ class Setter(Method):
self._is_list_type = is_list_type self._is_list_type = is_list_type
self._reindex = reindex self._reindex = reindex
def __call__(self, instance, value, *args, **kw): def __call__(self, instance, *args, **kw):
o = instance._getDefaultAcquiredProperty(self._key, None, self._null, o = instance._getDefaultAcquiredProperty(self._key, None, self._null,
base_category=self._acquisition_base_category, base_category=self._acquisition_base_category,
portal_type=self._acquisition_portal_type, portal_type=self._acquisition_portal_type,
...@@ -155,8 +155,7 @@ class Setter(Method): ...@@ -155,8 +155,7 @@ class Setter(Method):
from Products.ERP5Type.Utils import assertAttributePortalType from Products.ERP5Type.Utils import assertAttributePortalType
assertAttributePortalType(instance, self._storage_id, self._portal_type) assertAttributePortalType(instance, self._storage_id, self._portal_type)
o = instance.newContent(id = self._storage_id, portal_type = self._portal_type[0]) o = instance.newContent(id = self._storage_id, portal_type = self._portal_type[0])
kw = {self._acquired_property : value}
if self._reindex: if self._reindex:
o.edit(**kw) o.setProperty(self._acquired_property, *args, **kw)
else: else:
o._edit(**kw) o._setProperty(self._acquired_property, *args, **kw)
...@@ -159,8 +159,8 @@ class Getter(Method): ...@@ -159,8 +159,8 @@ class Getter(Method):
for k in self._storage_id_list: for k in self._storage_id_list:
o = getattr(instance, k, None) o = getattr(instance, k, None)
if o is not None and o.portal_type in self._portal_type: if o is not None and o.portal_type in self._portal_type:
#return o.getRelativeUrl() return o.getRelativeUrl()
return o #return o
return default_result return default_result
class ListGetter(Method): class ListGetter(Method):
......
...@@ -131,7 +131,7 @@ class Getter(Method): ...@@ -131,7 +131,7 @@ class Getter(Method):
# Generic Definition of Method Object # Generic Definition of Method Object
# This is required to call the method form the Web # This is required to call the method form the Web
func_code = func_code() func_code = func_code()
func_code.co_varnames = ('self',) func_code.co_varnames = ('self', 'args', 'kw')
func_code.co_argcount = 1 func_code.co_argcount = 1
func_defaults = () func_defaults = ()
...@@ -176,8 +176,8 @@ class Setter(Method): ...@@ -176,8 +176,8 @@ class Setter(Method):
# Generic Definition of Method Object # Generic Definition of Method Object
# This is required to call the method form the Web # This is required to call the method form the Web
func_code = func_code() func_code = func_code()
func_code.co_varnames = ('self',) func_code.co_varnames = ('self', 'value', 'args', 'kw')
func_code.co_argcount = 1 func_code.co_argcount = 2
func_defaults = () func_defaults = ()
def __init__(self, id, key, property_type, acquired_property, portal_type=None, storage_id=None, reindex=0): def __init__(self, id, key, property_type, acquired_property, portal_type=None, storage_id=None, reindex=0):
...@@ -197,27 +197,26 @@ class Setter(Method): ...@@ -197,27 +197,26 @@ class Setter(Method):
self._acquired_property = acquired_property self._acquired_property = acquired_property
self._reindex = reindex self._reindex = reindex
def __call__(self, instance, value, *args, **kw): def __call__(self, instance, *args, **kw):
# We return the first available object in the list # We return the first available object in the list
o = None o = None
kw = {self._acquired_property : value}
available_id = None available_id = None
for k in self._storage_id_list: for k in self._storage_id_list:
o = getattr(instance, k, None) o = getattr(instance, k, None)
if o is None: available_id = k if o is None: available_id = k
if o is not None and o.portal_type in self._portal_type: if o is not None and o.portal_type in self._portal_type:
if self._reindex: if self._reindex:
o.edit(**kw) o.setProperty(self._acquired_property, *args, **kw)
else: else:
o._edit(**kw) o._setProperty(self._acquired_property, *args, **kw)
if o is None and available_id is not None: if o is None and available_id is not None:
from Products.ERP5Type.Utils import assertAttributePortalType from Products.ERP5Type.Utils import assertAttributePortalType
assertAttributePortalType(instance, self._storage_id, self._portal_type) assertAttributePortalType(instance, available_id, self._portal_type)
o = instance.newContent(id = available_id, portal_type = self._portal_type[0]) o = instance.newContent(id = available_id, portal_type = self._portal_type[0])
if self._reindex: if self._reindex:
o.edit(**kw) o.setProperty(self._acquired_property, *args, **kw)
else: else:
o._edit(**kw) o._setProperty(self._acquired_property, *args, **kw)
class ListGetter(Method): class ListGetter(Method):
""" """
......
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