Commit 9cf48bd9 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Fix the warnings Init Ambiguous Name.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3916 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 93321c90
...@@ -28,15 +28,37 @@ ...@@ -28,15 +28,37 @@
from MethodObject import Method from MethodObject import Method
from copy import copy from copy import copy
import sys
from zLOG import LOG
class Accessor(Method): class Accessor(Method):
""" """
Generic Accessor - placehold for common methods Generic Accessor - placehold for common methods
""" """
def __getinitargs__(self):
init = getattr(self, '__init__', None)
if init is not None:
varnames = init.func_code.co_varnames
args = []
for name in varnames:
if name == 'self':
continue
else:
args.append(getattr(self, '_' + name))
return tuple(args)
return ()
def dummy_copy(self, id): def dummy_copy(self, id):
# Copy an accessor and change its id/name # Copy an accessor and change its id/name
self.__call__ = None #self.__call__ = None
#try:
# clone_instance = self.__class__(*self.__getinitargs__())
#except:
# LOG('dummy_copy', 0, '%r could not be generated with %r' % (id, self.__class__), error=sys.exc_info())
# raise
clone_instance = copy(self) clone_instance = copy(self)
delattr(self, '__call__') #delattr(self, '__call__')
#if hasattr(clone_instance, '__call__'):
# delattr(clone_instance, '__call__')
clone_instance.__name__ = id clone_instance.__name__ = id
return clone_instance return clone_instance
...@@ -42,7 +42,7 @@ class DefaultGetter(Method): ...@@ -42,7 +42,7 @@ class DefaultGetter(Method):
func_code.co_argcount = 1 func_code.co_argcount = 1
func_defaults = () func_defaults = ()
def __init__(self, id, key, property_type, default_value, def __init__(self, id, key, property_type, default,
acquisition_base_category, acquisition_base_category,
acquisition_portal_type, acquisition_portal_type,
acquisition_accessor_id, acquisition_accessor_id,
...@@ -57,9 +57,9 @@ class DefaultGetter(Method): ...@@ -57,9 +57,9 @@ class DefaultGetter(Method):
self._id = id self._id = id
self.__name__ = id self.__name__ = id
self._key = key self._key = key
self._type = property_type self._property_type = property_type
self._null = type_definition[property_type]['null'] self._null = type_definition[property_type]['null']
self._default = default_value self._default = default
self._acquisition_base_category = acquisition_base_category self._acquisition_base_category = acquisition_base_category
self._acquisition_portal_type = acquisition_portal_type self._acquisition_portal_type = acquisition_portal_type
self._acquisition_accessor_id = acquisition_accessor_id self._acquisition_accessor_id = acquisition_accessor_id
...@@ -116,7 +116,7 @@ class ListGetter(Method): ...@@ -116,7 +116,7 @@ class ListGetter(Method):
func_code.co_argcount = 1 func_code.co_argcount = 1
func_defaults = () func_defaults = ()
def __init__(self, id, key, property_type, default_value, def __init__(self, id, key, property_type, default,
acquisition_base_category, acquisition_base_category,
acquisition_portal_type, acquisition_portal_type,
acquisition_accessor_id, acquisition_accessor_id,
...@@ -131,9 +131,9 @@ class ListGetter(Method): ...@@ -131,9 +131,9 @@ class ListGetter(Method):
self._id = id self._id = id
self.__name__ = id self.__name__ = id
self._key = key self._key = key
self._type = property_type self._property_type = property_type
self._null = type_definition[property_type]['null'] self._null = type_definition[property_type]['null']
self._default = default_value self._default = default
self._acquisition_base_category = acquisition_base_category self._acquisition_base_category = acquisition_base_category
self._acquisition_portal_type = acquisition_portal_type self._acquisition_portal_type = acquisition_portal_type
self._acquisition_accessor_id = acquisition_accessor_id self._acquisition_accessor_id = acquisition_accessor_id
......
...@@ -58,7 +58,7 @@ class Getter(Method): ...@@ -58,7 +58,7 @@ class Getter(Method):
self._id = id self._id = id
self.__name__ = id self.__name__ = id
self._key = key self._key = key
self._type = property_type self._property_type = property_type
self._portal_type = portal_type self._portal_type = portal_type
self._null = type_definition[property_type]['null'] self._null = type_definition[property_type]['null']
self._acquisition_base_category = acquisition_base_category self._acquisition_base_category = acquisition_base_category
...@@ -129,7 +129,7 @@ class Setter(Method): ...@@ -129,7 +129,7 @@ class Setter(Method):
self._id = id self._id = id
self.__name__ = id self.__name__ = id
self._key = key self._key = key
self._type = property_type self._property_type = property_type
self._portal_type = portal_type self._portal_type = portal_type
self._null = type_definition[property_type]['null'] self._null = type_definition[property_type]['null']
self._acquisition_base_category = acquisition_base_category self._acquisition_base_category = acquisition_base_category
......
...@@ -118,13 +118,13 @@ class Getter(Method): ...@@ -118,13 +118,13 @@ class Getter(Method):
func_code.co_argcount = 1 func_code.co_argcount = 1
func_defaults = () func_defaults = ()
def __init__(self, id, key, property_type, default_value=None, storage_id=None): def __init__(self, id, key, property_type, default=None, storage_id=None):
self._id = id self._id = id
self.__name__ = id self.__name__ = id
self._key = key self._key = key
self._type = property_type self._property_type = property_type
self._null = type_definition[property_type]['null'] self._null = type_definition[property_type]['null']
self._default = default_value self._default = default
if storage_id is None: if storage_id is None:
storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key) storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key)
self._storage_id = storage_id self._storage_id = storage_id
...@@ -162,7 +162,7 @@ class Tester(Method): ...@@ -162,7 +162,7 @@ class Tester(Method):
self._id = id self._id = id
self.__name__ = id self.__name__ = id
self._key = key self._key = key
self._type = property_type self._property_type = property_type
self._null = type_definition[property_type]['null'] self._null = type_definition[property_type]['null']
if storage_id is None: if storage_id is None:
storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key) storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key)
......
...@@ -55,14 +55,14 @@ class ValueGetter(Method): ...@@ -55,14 +55,14 @@ class ValueGetter(Method):
self._id = id self._id = id
self.__name__ = id self.__name__ = id
self._key = key self._key = key
self._type = property_type self._property_type = property_type
self._null = type_definition[property_type]['null'] self._null = type_definition[property_type]['null']
self._default = default self._default = default
if storage_id is None: if storage_id is None:
storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key) storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key)
elif type(storage_id) not in (type([]), type(())): elif type(storage_id) not in (type([]), type(())):
storage_id = [storage_id] storage_id = [storage_id]
self._storage_id_list = storage_id self._storage_id = storage_id
if type(portal_type) is type('a'): if type(portal_type) is type('a'):
portal_type = (portal_type,) portal_type = (portal_type,)
self._portal_type = portal_type self._portal_type = portal_type
...@@ -77,7 +77,7 @@ class ValueGetter(Method): ...@@ -77,7 +77,7 @@ class ValueGetter(Method):
#LOG('ValueGetter.__call__, default',0,self._default) #LOG('ValueGetter.__call__, default',0,self._default)
#LOG('ValueGetter.__call__, storage_id_list',0,self._storage_id_list) #LOG('ValueGetter.__call__, storage_id_list',0,self._storage_id_list)
#LOG('ValueGetter.__call__, portal_type',0,self._portal_type) #LOG('ValueGetter.__call__, portal_type',0,self._portal_type)
for k in self._storage_id_list: for k in self._storage_id:
o = getattr(instance, k, None) o = getattr(instance, k, None)
#LOG('ValueGetter.__call__, o',0,o) #LOG('ValueGetter.__call__, o',0,o)
if o is not None and (o.portal_type is None or o.portal_type in self._portal_type): if o is not None and (o.portal_type is None or o.portal_type in self._portal_type):
...@@ -105,19 +105,19 @@ class ValueListGetter(Method): ...@@ -105,19 +105,19 @@ class ValueListGetter(Method):
self._id = id self._id = id
self.__name__ = id self.__name__ = id
self._key = key self._key = key
self._type = property_type self._property_type = property_type
self._null = type_definition[property_type]['null'] self._null = type_definition[property_type]['null']
self._default = default self._default = default
if storage_id is None: if storage_id is None:
storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key) storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key)
elif type(storage_id) is not type([]): elif type(storage_id) is not type([]):
storage_id = [storage_id] storage_id = [storage_id]
self._storage_id_list = storage_id self._storage_id = storage_id
self._portal_type = portal_type self._portal_type = portal_type
def __call__(self, instance, *args, **kw): def __call__(self, instance, *args, **kw):
# We return the list of matching objects # We return the list of matching objects
return [o.getObject() for o in self.contentValues({'portal_type': self._portal_type, 'id': self._storage_id_list})] return [o.getObject() for o in self.contentValues({'portal_type': self._portal_type, 'id': self._storage_id})]
psyco.bind(__call__) psyco.bind(__call__)
...@@ -141,14 +141,14 @@ class Getter(Method): ...@@ -141,14 +141,14 @@ class Getter(Method):
self._id = id self._id = id
self.__name__ = id self.__name__ = id
self._key = key self._key = key
self._type = property_type self._property_type = property_type
self._null = type_definition[property_type]['null'] self._null = type_definition[property_type]['null']
self._default = default self._default = default
if storage_id is None: if storage_id is None:
storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key) storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key)
elif type(storage_id) is not type([]): elif type(storage_id) is not type([]):
storage_id = [storage_id] storage_id = [storage_id]
self._storage_id_list = storage_id self._storage_id = storage_id
if type(portal_type) is type('a'): if type(portal_type) is type('a'):
portal_type = (portal_type,) portal_type = (portal_type,)
self._portal_type = portal_type self._portal_type = portal_type
...@@ -160,7 +160,7 @@ class Getter(Method): ...@@ -160,7 +160,7 @@ class Getter(Method):
else: else:
default_result = self._default default_result = self._default
o = None o = None
for k in self._storage_id_list: for k in self._storage_id:
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()
...@@ -187,18 +187,18 @@ class ListGetter(Method): ...@@ -187,18 +187,18 @@ class ListGetter(Method):
self._id = id self._id = id
self.__name__ = id self.__name__ = id
self._key = key self._key = key
self._type = property_type self._property_type = property_type
self._null = type_definition[property_type]['null'] self._null = type_definition[property_type]['null']
if storage_id is None: if storage_id is None:
storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key) storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key)
elif type(storage_id) is not type([]): elif type(storage_id) is not type([]):
storage_id = [storage_id] storage_id = [storage_id]
self._storage_id_list = storage_id self._storage_id = storage_id
self._portal_type = portal_type self._portal_type = portal_type
def __call__(self, instance, *args, **kw): def __call__(self, instance, *args, **kw):
# We return the list of matching objects # We return the list of matching objects
return [o.relative_url for o in self.searchFolder(portal_type = self._portal_type, id = self._storage_id_list)] return [o.relative_url for o in self.searchFolder(portal_type = self._portal_type, id = self._storage_id)]
psyco.bind(__call__) psyco.bind(__call__)
...@@ -221,7 +221,7 @@ class Tester(Method): ...@@ -221,7 +221,7 @@ class Tester(Method):
self._id = id self._id = id
self.__name__ = id self.__name__ = id
self._key = key self._key = key
self._type = property_type self._property_type = property_type
self._null = type_definition[property_type]['null'] self._null = type_definition[property_type]['null']
if storage_id is None: if storage_id is None:
storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key) storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key)
......
...@@ -55,7 +55,7 @@ class ValueGetter(Method): ...@@ -55,7 +55,7 @@ class ValueGetter(Method):
self._id = id self._id = id
self.__name__ = id self.__name__ = id
self._key = key self._key = key
self._type = property_type self._property_type = property_type
self._null = type_definition[property_type]['null'] self._null = type_definition[property_type]['null']
self._default = default self._default = default
if storage_id is None: if storage_id is None:
...@@ -106,7 +106,7 @@ class ValueListGetter(Method): ...@@ -106,7 +106,7 @@ class ValueListGetter(Method):
self._id = id self._id = id
self.__name__ = id self.__name__ = id
self._key = key self._key = key
self._type = property_type self._property_type = property_type
self._null = type_definition[property_type]['null'] self._null = type_definition[property_type]['null']
self._default = default self._default = default
if storage_id is None: if storage_id is None:
...@@ -143,7 +143,7 @@ class Getter(Method): ...@@ -143,7 +143,7 @@ class Getter(Method):
self._id = id self._id = id
self.__name__ = id self.__name__ = id
self._key = key self._key = key
self._type = property_type self._property_type = property_type
self._null = type_definition[property_type]['null'] self._null = type_definition[property_type]['null']
self._default = default self._default = default
if storage_id is None: if storage_id is None:
...@@ -190,7 +190,7 @@ class Setter(Method): ...@@ -190,7 +190,7 @@ class Setter(Method):
self._id = id self._id = id
self.__name__ = id self.__name__ = id
self._key = key self._key = key
self._type = property_type self._property_type = property_type
self._null = type_definition[property_type]['null'] self._null = type_definition[property_type]['null']
if storage_id is None: if storage_id is None:
storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key) storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key)
...@@ -242,7 +242,7 @@ class ListGetter(Method): ...@@ -242,7 +242,7 @@ class ListGetter(Method):
self._id = id self._id = id
self.__name__ = id self.__name__ = id
self._key = key self._key = key
self._type = property_type self._property_type = property_type
self._null = type_definition[property_type]['null'] self._null = type_definition[property_type]['null']
if storage_id is None: if storage_id is None:
storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key) storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key)
...@@ -277,7 +277,7 @@ class Tester(Method): ...@@ -277,7 +277,7 @@ class Tester(Method):
self._id = id self._id = id
self.__name__ = id self.__name__ = id
self._key = key self._key = key
self._type = property_type self._property_type = property_type
self._null = type_definition[property_type]['null'] self._null = type_definition[property_type]['null']
if storage_id is None: if storage_id is None:
storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key) storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key)
......
...@@ -125,6 +125,7 @@ class Setter(DefaultSetter): ...@@ -125,6 +125,7 @@ class Setter(DefaultSetter):
# Call the private setter # Call the private setter
method = getattr(instance, '_' + self._id) method = getattr(instance, '_' + self._id)
method(*args, **kw) method(*args, **kw)
if self._reindex: instance.reindexObject() if self._reindex: instance.reindexObject()
ListSetter = Setter ListSetter = Setter
...@@ -226,13 +227,13 @@ class DefaultGetter(Method): ...@@ -226,13 +227,13 @@ class DefaultGetter(Method):
func_code.co_argcount = 1 func_code.co_argcount = 1
func_defaults = () func_defaults = ()
def __init__(self, id, key, property_type, default_value = None, storage_id=None): def __init__(self, id, key, property_type, default = None, storage_id=None):
self._id = id self._id = id
self.__name__ = id self.__name__ = id
self._key = key self._key = key
self._type = property_type self._property_type = property_type
self._null = type_definition[property_type]['null'] self._null = type_definition[property_type]['null']
self._default = default_value self._default = default
if storage_id is None: if storage_id is None:
storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key) storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key)
self._storage_id = storage_id self._storage_id = storage_id
...@@ -272,13 +273,13 @@ class ListGetter(Method): ...@@ -272,13 +273,13 @@ class ListGetter(Method):
func_code.co_argcount = 1 func_code.co_argcount = 1
func_defaults = () func_defaults = ()
def __init__(self, id, key, property_type, default_value=None, storage_id=None): def __init__(self, id, key, property_type, default=None, storage_id=None):
self._id = id self._id = id
self.__name__ = id self.__name__ = id
self._key = key self._key = key
self._type = property_type self._property_type = property_type
self._null = type_definition[property_type]['null'] self._null = type_definition[property_type]['null']
self._default = default_value self._default = default
if storage_id is None: if storage_id is None:
storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key) storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key)
self._storage_id = storage_id self._storage_id = storage_id
...@@ -294,6 +295,8 @@ class ListGetter(Method): ...@@ -294,6 +295,8 @@ class ListGetter(Method):
if list_value not in self._null: if list_value not in self._null:
if self._is_tales_type: if self._is_tales_type:
if kw.get('evaluate', 1): if kw.get('evaluate', 1):
if type(list_value) != type(''):
LOG('ListGetter', 0, 'instance = %r, self._storage_id = %r, list_value = %r' % (instance, self._storage_id, list_value,))
list_value = evaluateTales(instance=instance, value=list_value) list_value = evaluateTales(instance=instance, value=list_value)
else: else:
return list_value return list_value
......
...@@ -55,7 +55,7 @@ class ValueGetter(Method): ...@@ -55,7 +55,7 @@ class ValueGetter(Method):
self._id = id self._id = id
self.__name__ = id self.__name__ = id
self._key = key self._key = key
self._type = property_type self._property_type = property_type
self._null = type_definition[property_type]['null'] self._null = type_definition[property_type]['null']
if storage_id is None: if storage_id is None:
storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key) storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key)
...@@ -97,7 +97,7 @@ class ValueListGetter(Method): ...@@ -97,7 +97,7 @@ class ValueListGetter(Method):
self._id = id self._id = id
self.__name__ = id self.__name__ = id
self._key = key self._key = key
self._type = property_type self._property_type = property_type
self._null = type_definition[property_type]['null'] self._null = type_definition[property_type]['null']
if storage_id is None: if storage_id is None:
storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key) storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key)
...@@ -132,7 +132,7 @@ class Getter(Method): ...@@ -132,7 +132,7 @@ class Getter(Method):
self._id = id self._id = id
self.__name__ = id self.__name__ = id
self._key = key self._key = key
self._type = property_type self._property_type = property_type
self._null = type_definition[property_type]['null'] self._null = type_definition[property_type]['null']
if storage_id is None: if storage_id is None:
storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key) storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key)
...@@ -174,7 +174,7 @@ class ListGetter(Method): ...@@ -174,7 +174,7 @@ class ListGetter(Method):
self._id = id self._id = id
self.__name__ = id self.__name__ = id
self._key = key self._key = key
self._type = property_type self._property_type = property_type
self._null = type_definition[property_type]['null'] self._null = type_definition[property_type]['null']
if storage_id is None: if storage_id is None:
storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key) storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key)
...@@ -208,7 +208,7 @@ class Tester(Method): ...@@ -208,7 +208,7 @@ class Tester(Method):
self._id = id self._id = id
self.__name__ = id self.__name__ = id
self._key = key self._key = key
self._type = property_type self._property_type = property_type
self._null = type_definition[property_type]['null'] self._null = type_definition[property_type]['null']
if storage_id is None: if storage_id is None:
storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key) storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key)
......
...@@ -429,7 +429,7 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ): ...@@ -429,7 +429,7 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ):
for prop in PropertySheet.Base._properties: for prop in PropertySheet.Base._properties:
if prop['id'] == 'id': if prop['id'] == 'id':
getId = BaseAccessor.Getter('getId', 'id', prop['type'], getId = BaseAccessor.Getter('getId', 'id', prop['type'],
default_value = prop.get('default'), storage_id = prop.get('storage_id')) default = prop.get('default'), storage_id = prop.get('storage_id'))
break break
# Debug # Debug
......
This diff is collapsed.
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