Commit a070d0a6 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Always try a property if a field is prefixed with my_, when getting a default value.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@8844 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c9496701
...@@ -113,25 +113,19 @@ def get_value(self, id, **kw): ...@@ -113,25 +113,19 @@ def get_value(self, id, **kw):
# call wrapped method to get answer # call wrapped method to get answer
value = override.__of__(self)() value = override.__of__(self)()
else: else:
# get normal value # Get a normal value.
value = self.get_orig_value(id) value = self.get_orig_value(id)
# For the 'default' value, we try to get a default value # For the 'default' value, we try to get a property value
if id == 'default': # stored in the context, only if the field is prefixed with my_.
if (value is None or value == '' or value == [] or value == ()) \ if id == 'default' and self.id[:3] == 'my_':
and self.meta_type != 'MethodField' : try:
# If nothing was provided then try to form = self.aq_parent
# find a default method to get the value ob = getattr(form, 'aq_parent', None)
# for that field key = self.id[3:]
# NEEDS TO BE CLEANED UP value = ob.getProperty(key, d=value)
try: except (KeyError, AttributeError):
form = self.aq_parent value = None
object = getattr(form, 'aq_parent', None)
key = self.id
key = key[3:]
value = object.getProperty(key, d=value)
except (KeyError, AttributeError):
value = None
# For the 'editable' value, we try to get a default value # For the 'editable' value, we try to get a default value
elif id == 'editable': elif id == 'editable':
# By default, pages are editable and # By default, pages are editable and
......
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