Commit 954790df authored by Jérome Perrin's avatar Jérome Perrin

save a call to pt_getContext

do not use 'object' name



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@12181 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent aeb4c4c6
...@@ -50,7 +50,7 @@ import sys ...@@ -50,7 +50,7 @@ import sys
from Products.Formulator.Field import Field from Products.Formulator.Field import Field
from zLOG import LOG from zLOG import LOG, PROBLEM
def get_value(self, id, **kw): def get_value(self, id, **kw):
"""Get value for id.""" """Get value for id."""
...@@ -59,24 +59,22 @@ def get_value(self, id, **kw): ...@@ -59,24 +59,22 @@ def get_value(self, id, **kw):
self.tales = {} self.tales = {}
tales_expr = self.tales.get(id, "") tales_expr = self.tales.get(id, "")
# tales_expr = self.get_tales(id)
if tales_expr: if tales_expr:
REQUEST = get_request() REQUEST = get_request()
form = self.aq_parent # XXX (JPS) form for default is wrong apparently in listbox - double check form = self.aq_parent # XXX (JPS) form for default is wrong apparently in listbox - double check
object = getattr(form, 'aq_parent', None) obj = getattr(form, 'aq_parent', None)
if object is not None: if obj is not None:
container = object.aq_inner.aq_parent container = obj.aq_inner.aq_parent
#container = object.aq_parent # This was the version used for long - I see no reason to do this
else: else:
container = None container = None
kw['field'] = self kw['field'] = self
kw['form'] = form kw['form'] = form
kw['request'] = REQUEST kw['request'] = REQUEST
kw['here'] = object kw['here'] = obj
kw['modules'] = SecureModuleImporter kw['modules'] = SecureModuleImporter
kw['container'] = container kw['container'] = container
try : try :
kw['preferences'] = object.getPortalObject().portal_preferences kw['preferences'] = obj.getPortalObject().portal_preferences
except AttributeError : except AttributeError :
LOG('ERP5Form', 0, LOG('ERP5Form', 0,
'portal_preferences not put in TALES context (not installed?)') 'portal_preferences not put in TALES context (not installed?)')
...@@ -101,8 +99,9 @@ def get_value(self, id, **kw): ...@@ -101,8 +99,9 @@ def get_value(self, id, **kw):
except: except:
# We add this safety exception to make sure we always get # We add this safety exception to make sure we always get
# something reasonable rather than generate plenty of errors # something reasonable rather than generate plenty of errors
LOG('ERP5Form.get_value ( %s/%s [%s]), exception on tales_expr: '%( LOG('ERP5Form', PROBLEM,
self.aq_parent.getId(), self.getId(), id) ,0,'', error=sys.exc_info()) 'Field.get_value ( %s/%s [%s]), exception on tales_expr: ' %
( form.getId(), self.getId(), id), error=sys.exc_info())
value = self.get_orig_value(id) value = self.get_orig_value(id)
else: else:
# FIXME: backwards compat hack to make sure overrides dict exists # FIXME: backwards compat hack to make sure overrides dict exists
...@@ -110,7 +109,6 @@ def get_value(self, id, **kw): ...@@ -110,7 +109,6 @@ def get_value(self, id, **kw):
self.overrides = {} self.overrides = {}
override = self.overrides.get(id, "") override = self.overrides.get(id, "")
# override = self.get_override(id)
if override: if override:
# call wrapped method to get answer # call wrapped method to get answer
value = override.__of__(self)() value = override.__of__(self)()
...@@ -386,22 +384,19 @@ class ERP5Form(ZMIForm, ZopePageTemplate): ...@@ -386,22 +384,19 @@ class ERP5Form(ZMIForm, ZopePageTemplate):
if not kwargs.has_key('args'): if not kwargs.has_key('args'):
kwargs['args'] = args kwargs['args'] = args
form = self form = self
object = getattr(form, 'aq_parent', None) obj = getattr(form, 'aq_parent', None)
if object is not None: if obj is not None:
container = object.aq_inner.aq_parent container = obj.aq_inner.aq_parent
if not _checkPermission(Permissions.View, object): if not _checkPermission(Permissions.View, obj):
raise AccessControl_Unauthorized('This document is not authorizes for view.') raise AccessControl_Unauthorized('This document is not authorized for view.')
else: else:
container = None container = None
pt = getattr(self,self.pt) pt = getattr(self,self.pt)
extra_context = self.pt_getContext() extra_context = dict( container=container,
extra_context['options'] = kwargs template=self,
extra_context['form'] = self form=self,
extra_context['container'] = container ## PROBLEM NOT TAKEN INTO ACCOUNT options=kwargs,
extra_context['here'] = object here=obj )
# We initialize here an index which is used to generate
# different method ids for every field
request = extra_context['request']
return pt.pt_render(extra_context=extra_context) return pt.pt_render(extra_context=extra_context)
def _exec(self, bound_names, args, kw): def _exec(self, bound_names, args, kw):
......
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