[Twisted-web] exception in formless with a few nevow examples

Jp Calderone exarkun at divmod.com
Tue Jul 19 20:40:39 MDT 2005


On Wed, 20 Jul 2005 02:17:48 +0200, Marek Habersack <grendel at caudium.net> wrote:
>Hello,
>
>  This is my first post to the list and I'm quite a newcomer to twisted and
>nevow, so forgive me if the issue is already known. The problem is with some
>Nevow examples (e.g. formpost, userdb, db, customform, formbuilder - you can
>see the problem at
>http://nevowexamples.adytum.us/{formpost,db,customform,formbuilder}/), the
>following exception occurs when the samples are run:
>
> exceptions.NameError: global name 'cf' is not defined
>
>With the exception of userdb (which seems to give a slightly incorrect
>traceback for the exception), the problem seems to originate at line 449 in
>formless/webform.py:
>
>447  def formRenderer(ctx, data):
>448      cf = ctx.locate(iformless.IConfigurableFactory)
>449      return util.maybeDeferred(cf.locateConfigurable, ctx, configurableKey
>450                                  ).addCallback(_formRenderIt)
>
>I'm not sure whether my guess is correct, but I perhaps the local 'cf'
>variable has been garbage-collected before the _runCallbacks routine in
>twisted/internet/defer.py calls the _formRenderIt?
>

Objects never get garbage collected in Python until it is safe for them to be garbage collected.  When there is code relying on their existence that might yet execute, it is not safe.

The real problem is that _formRenderIt is an entirely separate function, and it thinks "cf" is a local, but it's totally not.  This is fixed in current svn trunk at HEAD, but was broken in the 0.4.1 release.

Of course, with this error fixed, the code path that can successfully execute is one that warns you that your application is written wrong.  So everything isn't /perfect/, but at least it becomes more apparent what the real problem is.

Jp



More information about the Twisted-web mailing list