Commit 8f5c7021 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Apply psyco for all getters. Also, rewrite some methods by using list comprehesions instead of map.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3175 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 6eb8eb8a
......@@ -27,6 +27,7 @@
##############################################################################
from Base import func_code, type_definition, list_types, ATTRIBUTE_PREFIX, Method
from Products.ERP5Type.PsycoWrapper import psyco
class DefaultGetter(Method):
"""
......@@ -98,6 +99,8 @@ class DefaultGetter(Method):
is_tales_type=is_tales_type
)
psyco.bind(__call__)
Getter = DefaultGetter
class ListGetter(Method):
......@@ -170,4 +173,6 @@ class ListGetter(Method):
is_tales_type=is_tales_type
)
psyco.bind(__call__)
SetGetter = ListGetter # ERROR
......@@ -27,6 +27,7 @@
##############################################################################
from Base import func_code, type_definition, list_types, ATTRIBUTE_PREFIX, Method
from Products.ERP5Type.PsycoWrapper import psyco
class Getter(Method):
"""
......@@ -96,6 +97,8 @@ class Getter(Method):
else:
return default
psyco.bind(__call__)
class Setter(Method):
"""
Gets the default reference of a relation
......
......@@ -33,6 +33,7 @@ from Acquisition import aq_base
from zLOG import LOG
from Products.ERP5Type.Cache import CachingMethod
from Products.ERP5Type.PsycoWrapper import psyco
# Creation of default constructor
class func_code: pass
......@@ -140,6 +141,8 @@ class Getter(Method):
return value
return default
psyco.bind(__call__)
class Tester(Method):
"""
Tests if an attribute value exists
......
......@@ -28,6 +28,7 @@
from Base import func_code, type_definition, list_types, ATTRIBUTE_PREFIX, Method
from zLOG import LOG
from Products.ERP5Type.PsycoWrapper import psyco
class Setter(Method):
"""
......@@ -143,6 +144,7 @@ class DefaultGetter(Method):
filter=kw.get('filter', None),
portal_type=kw.get('portal_type',()),
base=0)
psyco.bind(__call__)
class ListGetter(Method):
"""
......@@ -164,6 +166,7 @@ class ListGetter(Method):
def __call__(self, instance, *args, **kw):
return instance._getAcquiredCategoryMembershipList(self._key, base=0, **kw)
psyco.bind(__call__)
SetGetter = ListGetter # XXX ERROR
......@@ -190,5 +193,7 @@ class ItemListGetter(Method):
def __call__(self, instance, *args, **kw):
return instance._getAcquiredCategoryMembershipItemList(self._key, base=0, **kw)
psyco.bind(__call__)
# And Tester ???
......@@ -28,6 +28,7 @@
from Base import func_code, type_definition, list_types, ATTRIBUTE_PREFIX, Method
import Base
from Products.ERP5Type.PsycoWrapper import psyco
Setter = Base.Setter
DefaultSetter = Base.Setter
......@@ -84,6 +85,8 @@ class ValueGetter(Method):
return o
return default_result
psyco.bind(__call__)
class ValueListGetter(Method):
"""
Gets an attribute value. A default value can be
......@@ -114,8 +117,9 @@ class ValueListGetter(Method):
def __call__(self, instance, *args, **kw):
# We return the list of matching objects
return map(lambda o:o.getObject(),
self.contentValues({'portal_type': self._portal_type, 'id': self._storage_id_list}))
return [o.getObject() for x in self.contentValues({'portal_type': self._portal_type, 'id': self._storage_id_list})]
psyco.bind(__call__)
DefaultValueGetter = ValueGetter
......@@ -163,6 +167,8 @@ class Getter(Method):
#return o
return default_result
psyco.bind(__call__)
class ListGetter(Method):
"""
Gets an attribute value. A default value can be
......@@ -192,8 +198,9 @@ class ListGetter(Method):
def __call__(self, instance, *args, **kw):
# We return the list of matching objects
return map(lambda o:o.relative_url,
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_list)]
psyco.bind(__call__)
DefaultGetter = Getter
......
......@@ -28,6 +28,7 @@
from Base import func_code, type_definition, list_types, ATTRIBUTE_PREFIX, Method
import Base
from Products.ERP5Type.PsycoWrapper import psyco
Setter = Base.Setter
DefaultSetter = Base.Setter
......@@ -85,6 +86,8 @@ class ValueGetter(Method):
return o
return default_result
psyco.bind(__call__)
class ValueListGetter(Method):
"""
Gets an attribute value. A default value can be
......@@ -116,8 +119,9 @@ class ValueListGetter(Method):
def __call__(self, instance, *args, **kw):
# We return the list of matching objects
return map(lambda o:o.getObject(),
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_list})]
psyco.bind(__call__)
DefaultValueGetter = ValueGetter
......@@ -166,6 +170,8 @@ class Getter(Method):
return o.getProperty(self._acquired_property, default)
return default
psyco.bind(__call__)
class Setter(Method):
"""
Gets an attribute value. A default value can be
......@@ -248,8 +254,9 @@ class ListGetter(Method):
def __call__(self, instance, *args, **kw):
# We return the list of matching objects
return map(lambda o:o.relative_url,
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_list)]
psyco.bind(__call__)
DefaultGetter = Getter
......
......@@ -33,6 +33,7 @@ import Base
from Products.CMFCore.Expression import Expression
from Products.ERP5Type.Utils import createExpressionContext
from Products.ERP5Type.Cache import CachingMethod
from Products.ERP5Type.PsycoWrapper import psyco
from zLOG import LOG
......@@ -253,6 +254,8 @@ class DefaultGetter(Method):
return list_value[0]
return default
psyco.bind(__call__)
Getter = DefaultGetter
class ListGetter(Method):
......@@ -297,6 +300,8 @@ class ListGetter(Method):
return list(list_value)
return default
psyco.bind(__call__)
SetGetter = ListGetter
Tester = Base.Tester
......@@ -28,6 +28,7 @@
from Base import func_code, type_definition, list_types, ATTRIBUTE_PREFIX, Method
import Base
from Products.ERP5Type.PsycoWrapper import psyco
Setter = Base.Setter
DefaultSetter = Base.Setter
......@@ -76,6 +77,8 @@ class ValueGetter(Method):
return o
return default_result
psyco.bind(__call__)
class ValueListGetter(Method):
"""
Gets an attribute value. A default value can be
......@@ -105,8 +108,9 @@ class ValueListGetter(Method):
def __call__(self, instance, *args, **kw):
# We return the list of matching objects
return map(lambda o:o.getObject(),
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_list})]
psyco.bind(__call__)
DefaultValueGetter = ValueGetter
......@@ -150,6 +154,8 @@ class Getter(Method):
return o.getRelativeUrl()
return default_result
psyco.bind(__call__)
class ListGetter(Method):
"""
Gets an attribute value. A default value can be
......@@ -179,8 +185,9 @@ class ListGetter(Method):
def __call__(self, instance, *args, **kw):
# We return the list of matching objects
return map(lambda o:o.relative_url,
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_list)]
psyco.bind(__call__)
DefaultGetter = Getter
......
......@@ -27,6 +27,7 @@
##############################################################################
from Base import func_code, type_definition, list_types, ATTRIBUTE_PREFIX, Method
from Products.ERP5Type.PsycoWrapper import psyco
class DefaultGetter(Method):
"""
......@@ -55,6 +56,8 @@ class DefaultGetter(Method):
filter=kw.get('filter', None),
portal_type=kw.get('portal_type',()))
psyco.bind(__call__)
Getter = DefaultGetter
class ListGetter(Method):
......@@ -84,4 +87,6 @@ class ListGetter(Method):
filter=kw.get('filter', None),
portal_type=kw.get('portal_type',()))
psyco.bind(__call__)
SetGetter = ListGetter
......@@ -27,6 +27,7 @@
##############################################################################
from Base import func_code, type_definition, list_types, ATTRIBUTE_PREFIX, Method
from Products.ERP5Type.PsycoWrapper import psyco
class DefaultGetter(Method):
"""
......@@ -55,6 +56,8 @@ class DefaultGetter(Method):
filter=kw.get('filter', None),
portal_type=kw.get('portal_type',()))
psyco.bind(__call__)
Getter = DefaultGetter
class ListGetter(Method):
......@@ -84,6 +87,8 @@ class ListGetter(Method):
filter=kw.get('filter', None),
portal_type=kw.get('portal_type',()))
psyco.bind(__call__)
SetGetter = ListGetter # Error XXX
class DefaultIdGetter(Method):
......@@ -113,6 +118,8 @@ class DefaultIdGetter(Method):
filter=kw.get('filter', None),
portal_type=kw.get('portal_type',()))
psyco.bind(__call__)
IdGetter = DefaultIdGetter
class IdListGetter(Method):
......@@ -142,6 +149,8 @@ class IdListGetter(Method):
filter=kw.get('filter', None),
portal_type=kw.get('portal_type',()))
psyco.bind(__call__)
IdSetGetter = IdListGetter # XXX Error
class DefaultTitleGetter(Method):
......@@ -171,6 +180,8 @@ class DefaultTitleGetter(Method):
filter=kw.get('filter', None),
portal_type=kw.get('portal_type',()))
psyco.bind(__call__)
TitleGetter = DefaultTitleGetter
class TitleListGetter(Method):
......@@ -200,6 +211,8 @@ class TitleListGetter(Method):
filter=kw.get('filter', None),
portal_type=kw.get('portal_type',()))
psyco.bind(__call__)
TitleSetGetter = TitleListGetter # XXX Error
class DefaultPropertyGetter(Method):
......@@ -229,6 +242,8 @@ class DefaultPropertyGetter(Method):
filter=kw.get('filter', None),
portal_type=kw.get('portal_type',()))
psyco.bind(__call__)
PropertyGetter = DefaultPropertyGetter
class PropertyListGetter(Method):
......@@ -258,4 +273,6 @@ class PropertyListGetter(Method):
filter=kw.get('filter', None),
portal_type=kw.get('portal_type',()))
psyco.bind(__call__)
PropertySetGetter = PropertyListGetter # Error XXX
......@@ -28,6 +28,7 @@
from Base import func_code, type_definition, list_types, ATTRIBUTE_PREFIX, Method
from zLOG import LOG
from Products.ERP5Type.PsycoWrapper import psyco
class Setter(Method):
"""
......@@ -53,6 +54,8 @@ class Setter(Method):
portal_type=kw.get('portal_type',()))
if self._reindex: instance.reindexObject()
psyco.bind(__call__)
ListSetter = Setter
SetSetter = Setter # Error XXX
DefaultSetter = Setter # Error XXX
......@@ -81,6 +84,8 @@ class DefaultGetter(Method):
LOG("ERP5Type Deprecated Getter Id:",0, self._id)
return instance._getDefaultAcquiredValue(self._key, **kw)
psyco.bind(__call__)
Getter = DefaultGetter
class ListGetter(Method):
......@@ -106,9 +111,11 @@ class ListGetter(Method):
def __call__(self, instance, *args, **kw):
if self._warning:
LOG("ERP5Type Deprecated Getter Id:",0, self._id)
LOG("__call__:",0, str((args,kw)))
#LOG("__call__:",0, str((args,kw)))
return instance._getAcquiredValueList(self._key, **kw)
psyco.bind(__call__)
SetGetter = ListGetter # Error XXX
......@@ -139,6 +146,8 @@ class DefaultTitleGetter(Method):
return None
return o.getTitle()
psyco.bind(__call__)
class TitleListGetter(Method):
"""
Gets a list of reference objects
......@@ -158,11 +167,13 @@ class TitleListGetter(Method):
self._key = key
def __call__(self, instance, *args, **kw):
return map(lambda x:x.getTitle(), instance._getAcquiredValueList(self._key,
return [x.getTitle() for x in instance._getAcquiredValueList(self._key,
spec=kw.get('spec',()),
filter=kw.get('filter', None),
portal_type=kw.get('portal_type',()))
)
]
psyco.bind(__call__)
TitleSetGetter = TitleListGetter # Error XXX
......@@ -194,6 +205,8 @@ class DefaultUidGetter(Method):
else:
return None
psyco.bind(__call__)
UidGetter = DefaultUidGetter
class UidListGetter(Method):
......@@ -215,11 +228,14 @@ class UidListGetter(Method):
self._key = key
def __call__(self, instance, *args, **kw):
return map(lambda x:x.getUid(), instance._getAcquiredValueList(self._key,
return [x.getUid() for x in instance._getAcquiredValueList(self._key,
spec=kw.get('spec',()),
filter=kw.get('filter', None),
portal_type=kw.get('portal_type',()))
)
]
psyco.bind(__call__)
UidSetGetter = UidListGetter # Error XXX
class UidSetter(Method):
......@@ -275,6 +291,8 @@ class DefaultIdGetter(Method):
else:
return None
psyco.bind(__call__)
IdGetter = DefaultIdGetter
class DefaultTitleOrIdGetter(Method):
......@@ -302,6 +320,8 @@ class DefaultTitleOrIdGetter(Method):
else:
return None
psyco.bind(__call__)
TitleOrIdGetter = DefaultTitleOrIdGetter
class DefaultLogicalPathGetter(Method):
......@@ -329,6 +349,8 @@ class DefaultLogicalPathGetter(Method):
else:
return None
psyco.bind(__call__)
LogicalPathGetter = DefaultLogicalPathGetter
class IdListGetter(Method):
......@@ -350,11 +372,13 @@ class IdListGetter(Method):
self._key = key
def __call__(self, instance, *args, **kw):
return map(lambda x:x.getId(), instance._getAcquiredValueList(self._key,
return [x.getId() for x in instance._getAcquiredValueList(self._key,
spec=kw.get('spec',()),
filter=kw.get('filter', None),
portal_type=kw.get('portal_type',()))
)
]
psyco.bind(__call__)
IdSetGetter = IdListGetter # Error XXX
......@@ -377,11 +401,11 @@ class LogicalPathListGetter(Method):
self._key = key
def __call__(self, instance, *args, **kw):
return map(lambda x:x.getLogicalPath(), instance._getAcquiredValueList(self._key,
return [x.getLogicalPath() for x in instance._getAcquiredValueList(self._key,
spec=kw.get('spec',()),
filter=kw.get('filter', None),
portal_type=kw.get('portal_type',()))
)
]
LogicalPathSetGetter = LogicalPathListGetter # Error XXX
......@@ -413,6 +437,8 @@ class DefaultPropertyGetter(Method):
else:
return None
psyco.bind(__call__)
PropertyGetter = DefaultPropertyGetter
class PropertyListGetter(Method):
......@@ -434,9 +460,12 @@ class PropertyListGetter(Method):
self._key = key
def __call__(self, instance, key, *args, **kw):
return map(lambda x:x.getProperty(key), instance._getAcquiredValueList(self._key,
return [x.getProperty(key) for x in instance._getAcquiredValueList(self._key,
spec=kw.get('spec',()),
filter=kw.get('filter', None),
portal_type=kw.get('portal_type',()))
)
]
psyco.bind(__call__)
PropertySetGetter = PropertyListGetter # Error XXX
......@@ -28,6 +28,7 @@
from Accessor import Accessor as Method
from Products.CMFCore.utils import getToolByName
from Products.ERP5Type.PsycoWrapper import psyco
# Creation of default constructor
class func_code: pass
......@@ -56,6 +57,8 @@ class Getter(Method):
wf = portal_workflow.getWorkflowById(self._key)
return wf._getWorkflowStateOf(instance, id_only=1)
psyco.bind(__call__)
class TitleGetter(Method):
"""
Gets the title of the current state
......@@ -78,4 +81,6 @@ class TitleGetter(Method):
portal_workflow = getToolByName(instance, 'portal_workflow')
wf = portal_workflow.getWorkflowById(self._key)
return wf._getWorkflowStateOf(instance).title
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