Commit 6662b155 authored by Nicolas Delaby's avatar Nicolas Delaby

Keep acquisition context of returned object.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@33641 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 09884eaa
...@@ -428,6 +428,8 @@ class ProxyField(ZMIField): ...@@ -428,6 +428,8 @@ class ProxyField(ZMIField):
except KeyError: except KeyError:
pass pass
portal = self.getPortalObject()
portal_skins = getToolByName(portal, 'portal_skins')
form = self.aq_parent form = self.aq_parent
object = form.aq_parent object = form.aq_parent
...@@ -438,17 +440,18 @@ class ProxyField(ZMIField): ...@@ -438,17 +440,18 @@ class ProxyField(ZMIField):
# If a / is in the form_id, it means that skin_folder is explicitly # If a / is in the form_id, it means that skin_folder is explicitly
# defined. If so, prevent acquisition to get the form. # defined. If so, prevent acquisition to get the form.
form_id_with_skin_folder_name_flag = True form_id_with_skin_folder_name_flag = True
proxy_form = aq_base(object.portal_skins).unrestrictedTraverse(form_id, None) proxy_form = aq_base(portal_skins).unrestrictedTraverse(form_id, None)
if proxy_form is not None:
proxy_form = portal_skins.unrestrictedTraverse(form_id)
else: else:
proxy_form = getattr(object, form_id, None) proxy_form = getattr(object, form_id, None)
if (proxy_form is not None): if (proxy_form is not None):
field_id = self.get_value('field_id') field_id = self.get_value('field_id')
try: proxy_field = getattr(aq_base(proxy_form), field_id, None)
proxy_field = aq_base(getattr(proxy_form, field_id)) if proxy_field is not None:
except (AttributeError, TypeError): proxy_field = getattr(proxy_form, field_id)
proxy_field = None else:
if form_id_with_skin_folder_name_flag is False: if form_id_with_skin_folder_name_flag is False:
# Try to get the field from another field library with a lower # Try to get the field from another field library with a lower
# priority. # priority.
...@@ -458,23 +461,20 @@ class ProxyField(ZMIField): ...@@ -458,23 +461,20 @@ class ProxyField(ZMIField):
if skin_info is not None: if skin_info is not None:
skin_selection_name, ignore, resolve = skin_info skin_selection_name, ignore, resolve = skin_info
portal_skins = aq_base(self.portal_skins)
selection_dict = portal_skins._getSelections() selection_dict = portal_skins._getSelections()
candidate_folder_id_list = selection_dict[skin_selection_name].split(',') candidate_folder_id_list = selection_dict[skin_selection_name].split(',')
for candidate_folder_id in candidate_folder_id_list: for candidate_folder_id in candidate_folder_id_list:
candidate_folder = getattr(portal_skins, candidate_folder_id, None) candidate_folder = portal_skins._getOb(candidate_folder_id, None)
if candidate_folder is not None: if candidate_folder is not None:
proxy_form = getattr(candidate_folder, form_id, None) proxy_form = candidate_folder._getOb(form_id, None)
if proxy_form is not None: if proxy_form is not None:
proxy_field = getattr(proxy_form, field_id, None) proxy_field = proxy_form._getOb(field_id, None)
if proxy_field is not None: if proxy_field is not None:
break break
if proxy_field is not None: if proxy_field is None:
proxy_field = proxy_field.__of__(form)
else:
LOG('ProxyField', WARNING, LOG('ProxyField', WARNING,
'Could not get a field from a proxy field %s in %s' % \ 'Could not get a field from a proxy field %s in %s' % \
(self.id, object.id)) (self.id, object.id))
......
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