[Erp5-report] r35389 yusuke - in /erp5/trunk/products/ERP5Type: ./ Accessor/
nobody at svn.erp5.org
nobody at svn.erp5.org
Mon May 17 14:38:24 CEST 2010
Author: yusuke
Date: Mon May 17 14:38:11 2010
New Revision: 35389
URL: http://svn.erp5.org?rev=35389&view=rev
Log:
fixed a bug #1790
Modified:
erp5/trunk/products/ERP5Type/Accessor/Translation.py
erp5/trunk/products/ERP5Type/Utils.py
Modified: erp5/trunk/products/ERP5Type/Accessor/Translation.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Accessor/Translation.py?rev=35389&r1=35388&r2=35389&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Accessor/Translation.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Accessor/Translation.py [utf8] Mon May 17 14:38:11 2010
@@ -31,7 +31,7 @@
from Acquisition import aq_base
from Products.CMFCore.utils import getToolByName
-from Products.ERP5Type.Accessor.Base import func_code, ATTRIBUTE_PREFIX, evaluateTales, Getter as BaseGetter
+from Products.ERP5Type.Accessor.Base import func_code, ATTRIBUTE_PREFIX, evaluateTales, Getter as BaseGetter, Method
from Products.ERP5Type.Accessor import Accessor, AcquiredProperty
from Products.ERP5Type.Accessor.TypeDefinition import type_definition
@@ -217,3 +217,41 @@
return value.getProperty(self._acquired_property, default, **kw)
else:
return default
+
+class TranslatedPropertyTester(Method):
+ """
+ Tests if an attribute value exists
+ """
+ _need__name__=1
+
+ # 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, property_id, property_type, language, warning=0):
+ self._id = id
+ self.__name__ = id
+ self._property_id = property_id
+ self._property_type = property_type
+ self._null = type_definition[property_type]['null']
+ self._language = language
+ self._warning = warning
+
+ def __call__(self, instance, *args, **kw):
+ if self._warning:
+ LOG("ERP5Type Deprecated Tester Id:",0, self._id)
+ domain = instance.getProperty('%s_translation_domain' % self._property_id)
+
+ if domain==TRANSLATION_DOMAIN_CONTENT_TRANSLATION:
+ if self._language is None:
+ language = kw.get('language') or getToolByName(instance, 'Localizer').get_selected_language()
+ else:
+ language = self._language
+ try:
+ return instance.getPropertyTranslation(self._property_id, language) is not None
+ except KeyError:
+ return False
+ else:
+ return instance.getProperty(self._property_id) is not None
Modified: erp5/trunk/products/ERP5Type/Utils.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Utils.py?rev=35389&r1=35388&r2=35389&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Utils.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Utils.py [utf8] Mon May 17 14:38:11 2010
@@ -2853,6 +2853,7 @@
composed_id = '%s_translated_%s' % (language_key, property['id'])
capitalised_compose_id = UpperCase(composed_id)
+ # get
getter_accessor_args = (property['id'], property['type'], language, default)
accessor_dict_list.append({'name': 'get' + capitalised_compose_id,
'class': Translation.TranslatedPropertyGetter,
@@ -2863,7 +2864,14 @@
'argument': getter_accessor_args,
'permission': read_permission})
- setter_accessor_args = (property['id'], property['type'], language)
+ # has
+ has_accessor_args = (property['id'], property['type'], language)
+ accessor_dict_list.append({'name': 'has' + capitalised_compose_id,
+ 'class': Translation.TranslatedPropertyTester,
+ 'argument': has_accessor_args,
+ 'permission': read_permission})
+
+ # set
accessor_dict_list.append({'name':'set' + capitalised_compose_id,
'key': '_set' + capitalised_compose_id,
'class': Alias.Reindex,
More information about the Erp5-report
mailing list