diff --git a/fields/__init__.py b/fields/__init__.py index b779cae..7acc4d7 100644 --- a/fields/__init__.py +++ b/fields/__init__.py @@ -685,6 +685,13 @@ class Field: obj.log(sutils.Traceback.get(), type='error') raise e + def getAttribute(self, obj, name): + '''Gets the value of attribue p_name on p_self, which can be a simple + value or the result of a method call on p_obj.''' + res = getattr(self, name) + if not callable(res): return res + return self.callMethod(obj, res) + def process(self, obj): '''This method is a general hook allowing a field to perform some processing after an URL on an object has been called, of the form diff --git a/fields/ref.py b/fields/ref.py index 670b948..e3e066f 100644 --- a/fields/ref.py +++ b/fields/ref.py @@ -277,7 +277,8 @@ class Ref(Field): (q(ajaxHookId), q(zobj.absolute_url()), \ q(field.name), q(innerRef)); changeOrder=False; - checkboxes=field.checkboxesEnabled(zobj) and (totalNumber > 1); + checkboxes=field.getAttribute(zobj, 'checkboxes') and \ + (totalNumber > 1); showSubTitles=showSubTitles|\ req.get('showSubTitles', 'true') == 'true'; subLabel='selectable_objects'">:field.pxViewList''') @@ -341,8 +342,8 @@ class Ref(Field): navBaseCall='askRefField(%s,%s,%s,%s,**v**)' % \ (q(ajaxHookId), q(zobj.absolute_url()), \ q(field.name), q(innerRef)); - changeOrder=field.changeOrderEnabled(zobj); - checkboxesEnabled=field.checkboxesEnabled(zobj); + changeOrder=field.getAttribute(zobj, 'changeOrder'); + checkboxesEnabled=field.getAttribute(zobj, 'checkboxes'); checkboxes=checkboxesEnabled and (totalNumber > 1); showSubTitles=req.get('showSubTitles', 'true') == 'true'">