[Zope-CMF] NameError: on global name 'context' is not defined

Tres Seaver tseaver@zope.com
11 Jun 2002 08:07:24 -0400


On Mon, 2002-06-10 at 13:13, alan runyan wrote:
> exceptions.NameError on global name 'context' is not defined in
> '<PythonExpr here.breadcrumbs(here)>',
> 
> I have been getting this alot lately.  I run Zope2.5.1+CMF1.3b1 w/ python
> 2.1.3 on linux.  I can tickle this bug sometimes after refreshing a Product.
> Recently it has been getting worse ;'(.  http://plone.org is suffering from
> these errors (it runs Zope2.5.1a + CMF1.3b1 + python2.1.3 on FreeBSD).  It
> seems that Plone 0.9.9+CMF1.3 didnt do this.  But Plone in CVS does cause
> this behavior.  I am not doing anything hokey to any of the tools.  I dont
> believe I get these problems when a script is loaded from within the ZODB.
> 
> I saw someone reporting this error on the mailing list but it seems like the
> thread went nowhere.


At a guess, do you have a (FS)PythonScript which is stored with
a special binding?  E.g.::

  ## Script (Python) "addtoFavorites"
  ##title=Add item to favourites
  ##bind namespace=_
  ##parameters=

If so, and if the body uses any of the "standard" bindings, they may be
stomped unless you re-bind them directly.  That header *should* be::

  ## Script (Python) "addtoFavorites"
  ##title=Add item to favourites
  ##bind container=container
  ##bind context=context
  ##bind namespace=_
  ##bind script=script
  ##bind subpath=traverse_subpath
  ##parameters=

or even just::

  ## Script (Python) "addtoFavorites"
  ##title=Add item to favourites
  ##bind context=context

as the body only depends on 'context'.  *Most* FSPythonScripts should
not have any '##bind' headers, as they use only the default bindings,
anyway.

Tres.
-- 
===============================================================
Tres Seaver                                tseaver@zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.com