Commit c56d77f3 authored by Jean-Paul Smets's avatar Jean-Paul Smets

Added support for LogicalPath


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3000 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 33ec56b8
......@@ -304,6 +304,33 @@ class DefaultTitleOrIdGetter(Method):
TitleOrIdGetter = DefaultTitleOrIdGetter
class DefaultLogicalPathGetter(Method):
"""
Gets a default logical path object
"""
_need__name__=1
# 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_defaults = ()
def __init__(self, id, key):
self._id = id
self.__name__ = id
self._key = key
def __call__(self, instance, *args, **kw):
value = instance._getDefaultAcquiredValue(self._key, spec=kw.get('spec',()))
if value is not None:
return value.getLogicalPath()
else:
return None
LogicalPathGetter = DefaultLogicalPathGetter
class IdListGetter(Method):
"""
Gets a list of reference objects uid
......@@ -331,6 +358,33 @@ class IdListGetter(Method):
IdSetGetter = IdListGetter # Error XXX
class LogicalPathListGetter(Method):
"""
Gets a list of logical path
"""
_need__name__=1
# 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_defaults = ()
def __init__(self, id, key):
self._id = id
self.__name__ = id
self._key = key
def __call__(self, instance, *args, **kw):
return map(lambda x:x.getLogicalPath(), instance._getAcquiredValueList(self._key,
spec=kw.get('spec',()),
filter=kw.get('filter', None),
portal_type=kw.get('portal_type',()))
)
LogicalPathSetGetter = LogicalPathListGetter # Error XXX
class DefaultPropertyGetter(Method):
"""
Gets a default reference object
......
......@@ -1984,6 +1984,24 @@ def createValueAccessors(klass, id):
if not hasattr(klass, accessor_name):
setattr(klass, accessor_name, accessor)
accessor_name = 'get' + UpperCase(id) + 'LogicalPathList'
accessor = Value.LogicalPathListGetter(accessor_name, id)
if not hasattr(klass, accessor_name):
setattr(klass, accessor_name, accessor)
klass.security.declareProtected(Permissions.AccessContentsInformation, accessor_name)
accessor_name = '_categoryGet' + UpperCase(id) + 'LogicalPathList'
if not hasattr(klass, accessor_name):
setattr(klass, accessor_name, accessor)
accessor_name = 'get' + UpperCase(id) + 'LogicalPathSet'
accessor = Value.LogicalPathSetGetter(accessor_name, id)
if not hasattr(klass, accessor_name):
setattr(klass, accessor_name, accessor)
klass.security.declareProtected(Permissions.AccessContentsInformation, accessor_name)
accessor_name = '_categoryGet' + UpperCase(id) + 'LogicalPathSet'
if not hasattr(klass, accessor_name):
setattr(klass, accessor_name, accessor)
accessor_name = 'get' + UpperCase(id) + 'UidList'
accessor = Value.UidListGetter(accessor_name, id)
if not hasattr(klass, accessor_name):
......@@ -2116,6 +2134,22 @@ def createValueAccessors(klass, id):
if not hasattr(klass, accessor_name):
setattr(klass, accessor_name, accessor)
accessor_name = 'getDefault' + UpperCase(id) + 'LogicalPath'
accessor = Value.DefaultLogicalPathGetter(accessor_name, id)
if not hasattr(klass, accessor_name):
setattr(klass, accessor_name, accessor)
klass.security.declareProtected(Permissions.AccessContentsInformation, accessor_name)
accessor_name = 'get' + UpperCase(id) + 'LogicalPath'
if not hasattr(klass, accessor_name):
setattr(klass, accessor_name, accessor)
klass.security.declareProtected(Permissions.AccessContentsInformation, accessor_name)
accessor_name = '_categoryGetDefault' + UpperCase(id) + 'LogicalPath'
if not hasattr(klass, accessor_name):
setattr(klass, accessor_name, accessor)
accessor_name = '_categoryGet' + UpperCase(id) + 'LogicalPath'
if not hasattr(klass, accessor_name):
setattr(klass, accessor_name, accessor)
setter_name = 'set' + UpperCase(id) + 'Value'
setter = Value.Setter(setter_name, id, reindex=1)
if not hasattr(klass, setter_name):
......
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