Commit 571bd069 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Add translated title getters.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@6015 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f5ffdf8f
......@@ -177,6 +177,64 @@ class TitleListGetter(Method):
TitleSetGetter = TitleListGetter # Error XXX
class DefaultTranslatedTitleGetter(Method):
"""
Gets a default reference 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):
o = instance._getDefaultAcquiredValue(self._key,
spec=kw.get('spec',()),
filter=kw.get('filter', None),
portal_type=kw.get('portal_type',()))
if o is None:
return None
return o.getTranslatedTitle()
psyco.bind(__call__)
class TranslatedTitleListGetter(Method):
"""
Gets a list of reference objects
"""
_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 [x.getTranslatedTitle() 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__)
TranslatedTitleSetGetter = TranslatedTitleListGetter # Error XXX
class DefaultReferenceGetter(Method):
"""
Gets a default reference object
......
......@@ -2128,6 +2128,24 @@ def createValueAccessors(property_holder, id,
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
accessor_name = 'get' + UpperCase(id) + 'TranslatedTitleList'
accessor = Value.TranslatedTitleListGetter(accessor_name, id)
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor)
property_holder.security.declareProtected(read_permission, accessor_name)
accessor_name = '_categoryGet' + UpperCase(id) + 'TranslatedTitleList'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
accessor_name = 'get' + UpperCase(id) + 'TranslatedTitleSet'
accessor = Value.TranslatedTitleSetGetter(accessor_name, id)
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor)
property_holder.security.declareProtected(read_permission, accessor_name)
accessor_name = '_categoryGet' + UpperCase(id) + 'TranslatedTitleSet'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
accessor_name = 'get' + UpperCase(id) + 'ReferenceList'
accessor = Value.ReferenceListGetter(accessor_name, id)
if not hasattr(property_holder, accessor_name):
......@@ -2255,6 +2273,22 @@ def createValueAccessors(property_holder, id,
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
accessor_name = 'getDefault' + UpperCase(id) + 'TranslatedTitle'
accessor = Value.DefaultTranslatedTitleGetter(accessor_name, id)
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor)
property_holder.security.declareProtected(read_permission, accessor_name)
accessor_name = 'get' + UpperCase(id) + 'TranslatedTitle'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
property_holder.security.declareProtected(read_permission, accessor_name)
accessor_name = '_categoryGetDefault' + UpperCase(id) + 'TranslatedTitle'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
accessor_name = '_categoryGet' + UpperCase(id) + 'TranslatedTitle'
if not hasattr(property_holder, accessor_name):
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
accessor_name = 'getDefault' + UpperCase(id) + 'Reference'
accessor = Value.DefaultReferenceGetter(accessor_name, id)
if not hasattr(property_holder, accessor_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