From 79470cfdc1a2621775895b62f6f96f3122fbaaab Mon Sep 17 00:00:00 2001
From: Jean-Paul Smets <jp@nexedi.com>
Date: Mon, 12 Jul 2004 21:57:39 +0000
Subject: [PATCH] multiple bugfixes after initial implementation

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@1172 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Type/Accessor/AcquiredProperty.py | 15 +++++++--------
 product/ERP5Type/Accessor/Content.py          |  4 ++--
 product/ERP5Type/Accessor/ContentProperty.py  | 19 +++++++++----------
 3 files changed, 18 insertions(+), 20 deletions(-)

diff --git a/product/ERP5Type/Accessor/AcquiredProperty.py b/product/ERP5Type/Accessor/AcquiredProperty.py
index 1abd54d9f4..84ca1b9937 100755
--- a/product/ERP5Type/Accessor/AcquiredProperty.py
+++ b/product/ERP5Type/Accessor/AcquiredProperty.py
@@ -37,8 +37,8 @@ class Getter(Method):
     # Generic Definition of Method Object
     # This is required to call the method form the Web
     func_code = func_code()
-    func_code.co_varnames = ('self',)
-    func_code.co_argcount = 1
+    func_code.co_varnames = ('self', 'instance', 'args', 'kw')
+    func_code.co_argcount = 2
     func_defaults = ()
 
     def __init__(self,  id, key, property_type, portal_type, acquired_property,
@@ -102,8 +102,8 @@ class Setter(Method):
     # Generic Definition of Method Object
     # This is required to call the method form the Web
     func_code = func_code()
-    func_code.co_varnames = ('self',)
-    func_code.co_argcount = 1
+    func_code.co_varnames = ('self', 'instance', 'args', 'kw')
+    func_code.co_argcount = 2
     func_defaults = ()
 
     def __init__(self,  id, key, property_type, portal_type, acquired_property,
@@ -139,7 +139,7 @@ class Setter(Method):
       self._is_list_type = is_list_type
       self._reindex = reindex
 
-    def __call__(self, instance, value, *args, **kw):             
+    def __call__(self, instance, *args, **kw):             
       o = instance._getDefaultAcquiredProperty(self._key, None, self._null,
             base_category=self._acquisition_base_category,
             portal_type=self._acquisition_portal_type,
@@ -155,8 +155,7 @@ class Setter(Method):
         from Products.ERP5Type.Utils import assertAttributePortalType   
         assertAttributePortalType(instance, self._storage_id, self._portal_type)
         o = instance.newContent(id = self._storage_id, portal_type = self._portal_type[0])
-      kw = {self._acquired_property : value}         
       if self._reindex:
-        o.edit(**kw)
+        o.setProperty(self._acquired_property, *args, **kw)
       else:
-        o._edit(**kw)
+        o._setProperty(self._acquired_property, *args, **kw)
diff --git a/product/ERP5Type/Accessor/Content.py b/product/ERP5Type/Accessor/Content.py
index dfc20be7d3..a481d94823 100755
--- a/product/ERP5Type/Accessor/Content.py
+++ b/product/ERP5Type/Accessor/Content.py
@@ -159,8 +159,8 @@ class Getter(Method):
       for k in self._storage_id_list:
         o = getattr(instance, k, None)
         if o is not None and o.portal_type in self._portal_type:
-          #return o.getRelativeUrl()
-          return o
+          return o.getRelativeUrl()
+          #return o
       return default_result
 
 class ListGetter(Method):
diff --git a/product/ERP5Type/Accessor/ContentProperty.py b/product/ERP5Type/Accessor/ContentProperty.py
index 2f539042d8..f39b22b288 100755
--- a/product/ERP5Type/Accessor/ContentProperty.py
+++ b/product/ERP5Type/Accessor/ContentProperty.py
@@ -131,7 +131,7 @@ class Getter(Method):
     # Generic Definition of Method Object
     # This is required to call the method form the Web
     func_code = func_code()
-    func_code.co_varnames = ('self',)
+    func_code.co_varnames = ('self', 'args', 'kw')
     func_code.co_argcount = 1
     func_defaults = ()
 
@@ -176,8 +176,8 @@ class Setter(Method):
     # Generic Definition of Method Object
     # This is required to call the method form the Web
     func_code = func_code()
-    func_code.co_varnames = ('self',)
-    func_code.co_argcount = 1
+    func_code.co_varnames = ('self', 'value', 'args', 'kw')
+    func_code.co_argcount = 2
     func_defaults = ()
 
     def __init__(self, id, key, property_type, acquired_property, portal_type=None, storage_id=None, reindex=0):
@@ -197,27 +197,26 @@ class Setter(Method):
       self._acquired_property = acquired_property
       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
       o = None
-      kw = {self._acquired_property : value}
       available_id = None
       for k in self._storage_id_list:
         o = getattr(instance, k, None)
         if o is None: available_id = k
         if o is not None and o.portal_type in self._portal_type:
           if self._reindex:
-            o.edit(**kw)
+            o.setProperty(self._acquired_property, *args, **kw)
           else:
-            o._edit(**kw)
+            o._setProperty(self._acquired_property, *args, **kw)
       if o is None and available_id is not None:
         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])
         if self._reindex:
-          o.edit(**kw)
+          o.setProperty(self._acquired_property, *args, **kw)
         else:
-          o._edit(**kw)
+          o._setProperty(self._acquired_property, *args, **kw)
 
 class ListGetter(Method):
     """
-- 
2.30.9