----- Original Message ----- From: "Jürgen Herrmann" <Juergen.Herrmann@XLhost.de> To: <zope@zope.org> Sent: Thursday, June 01, 2006 11:51 AM Subject: [Zope] global name 'context' not defined in TrustedFSPageTemplate
hi!
i get the following error in one of my trusted page template files:
Traceback (innermost last): * Module ZPublisher.Publish, line 113, in publish * Module ZPublisher.mapply, line 88, in mapply * Module ZPublisher.Publish, line 40, in call_object * Module Shared.DC.Scripts.Bindings, line 311, in __call__ * Module Shared.DC.Scripts.Bindings, line 348, in _bindAndExec * Module Products.CMFCore.FSPageTemplate, line 195, in _exec * Module Products.TrustedExecutables.TrustedFSPageTemplate, line 31, in pt_render * Module Products.PageTemplates.PageTemplate, line 104, in pt_render <TrustedFSPageTemplate at /bliss/BlissCalendar/show_content_week> * Module TAL.TALInterpreter, line 238, in __call__ * Module TAL.TALInterpreter, line 281, in interpret * Module TAL.TALInterpreter, line 507, in do_setLocal_tal * Module Products.PageTemplates.TALES, line 221, in evaluate URL: file:/home/bliss/zope/Products/BlissCalendar/www/BlissCalendar/show_content_week.xpt Line 3, Column 0 Expression: <PythonExpr dates.sort(lambda a,b: cmp(context.utils.text2date(a), context.utils.text2date(b)))> Names:
{'container': <BlissCalendar at /bliss/BlissCalendar>, 'context': <BlissCalendar at /bliss/BlissCalendar>, 'default': <Products.PageTemplates.TALES.Default instance at 0xb703850c>, 'here': <BlissCalendar at /bliss/BlissCalendar>, 'loop': <Products.PageTemplates.TALES.SafeMapping object at 0xb5d9426c>, 'modules': <Products.TrustedExecutables.TrustedExpression._ModuleImporter instance at 0xb6fa1b8c>, 'nothing': None, 'options': {'args': ()}, 'repeat': <Products.PageTemplates.TALES.SafeMapping object at 0xb5d9426c>, 'request': <HTTPRequest, URL=https://bliss.local/BlissCalendar/show_content_week>, 'root': <Application at >, 'template': <TrustedFSPageTemplate at /bliss/BlissCalendar/show_content_week>, 'traverse_subpath': [], 'user': <User at /bliss/data/Users/instances/juherm00 used for /bliss/acl_users>}
* Module Products.PageTemplates.PythonExpr, line 70, in __call__ __traceback_info__: dates.sort(lambda a,b: cmp(context.utils.text2date(a), context.utils.text2date(b))) * Module <string>, line 2, in f * Module <string>, line 2, in <lambda>
NameError: global name 'context' is not defined
Just a guess (the python gurus could answer this for sure), but lambda functions have access to variables in the containing scope, which in your case is the date.sort function. Does date.sort provide access to 'context'? A quick test would be to get rid of the lambda function and create a named function and see if that works.