malthe/chameleon — Issue #89: obscure cache problem while trying to render a small form
Author: muellert
Created: 2012-01-26 12:43:33+00:00
State: open

I experience a caching problem while trying to render a simple defom-generated form (two text input fields, one submit button):

2012-01-26 13:03:21,735 ERROR [pyramid_debugtoolbar][MainThread] Exception at http://127.0.0.1:6543/admin/login
traceback url: http://127.0.0.1:6543/_debug_toolbar/exception?token=a4a066901de7ab29b57f&tb=163581804
Traceback (most recent call last):
File "/home/zope/.virtualenvs/goe_newsletter/lib/python2.6/site-packages/pyramid_debugtoolbar-0.9.7-py2.6.egg/pyramid_debugtoolbar/toolbar.py", line 114, in toolbar_tween
response = _handler(request)
File "/home/zope/.virtualenvs/goe_newsletter/lib/python2.6/site-packages/pyramid_debugtoolbar-0.9.7-py2.6.egg/pyramid_debugtoolbar/panels/performance.py", line 55, in resource_timer_handler
result = handler(request)
File "/home/zope/.virtualenvs/goe_newsletter/lib/python2.6/site-packages/pyramid/tweens.py", line 20, in excview_tween
response = handler(request)
File "/home/zope/.virtualenvs/goe_newsletter/lib/python2.6/site-packages/pyramid_tm-0.3-py2.6.egg/pyramid_tm/__init__.py", line 61, in tm_tween
response = handler(request)
File "/home/zope/.virtualenvs/goe_newsletter/lib/python2.6/site-packages/pyramid/router.py", line 164, in handle_request
response = view_callable(context, request)
File "/home/zope/.virtualenvs/goe_newsletter/lib/python2.6/site-packages/pyramid/config/views.py", line 335, in rendered_view
context)
File "/home/zope/.virtualenvs/goe_newsletter/lib/python2.6/site-packages/pyramid/renderers.py", line 395, in render_view
return self.render_to_response(response, system, request=request)
File "/home/zope/.virtualenvs/goe_newsletter/lib/python2.6/site-packages/pyramid/renderers.py", line 424, in render_to_response
result = self.render(value, system_values, request=request)
File "/home/zope/.virtualenvs/goe_newsletter/lib/python2.6/site-packages/pyramid/renderers.py", line 420, in render
result = renderer(value, system_values)
File "/home/zope/.virtualenvs/goe_newsletter/lib/python2.6/site-packages/pyramid/chameleon_zpt.py", line 51, in __call__
result = self.template(**system)
File "/home/zope/.virtualenvs/goe_newsletter/lib/python2.6/site-packages/chameleon/template.py", line 128, in __call__
return self.render(**kwargs)
File "/home/zope/.virtualenvs/goe_newsletter/lib/python2.6/site-packages/chameleon/zpt/template.py", line 258, in render
return super(PageTemplate, self).render(**vars)
File "/home/zope/.virtualenvs/goe_newsletter/lib/python2.6/site-packages/chameleon/template.py", line 175, in render
self._render(stream, econtext, rcontext)
File "/tmp/tmp8occif/login_df_3bca46bddedeb3be09bc3f780fc44418b9b8e23f.py", line 197, in render
__macro.include(__stream, econtext.copy(), rcontext, __i18n_domain)
File "/home/zope/.virtualenvs/goe_newsletter/lib/python2.6/site-packages/chameleon/zpt/template.py", line 262, in include
self._render(*args, **kwargs)
File "/tmp/tmpGrlTVb/base_df_80c4facc0b656b3596c838a585e7f22a0ecff594.py", line 998, in render
__slot_content(__stream, econtext.copy(), rcontext)
File "/tmp/tmp8occif/login_df_3bca46bddedeb3be09bc3f780fc44418b9b8e23f.py", line 154, in __fill_content
__expression = __cache_163658188
NameError: global name '__cache_163658188' is not defined
localhost - - [26/Jan/2012 13:03:21] "GET /admin/login HTTP/1.1" 500 122801

I made some experiments and found that, using a different template, I can render the form just fine, so it generally should not be a problem with deform. The difference between the two templates is, that the one that works, is an all-in-one template with only a placeholder for the form, and the other is a TAL macro page that contains:

Login to project

My Form

uh oh

The all-in-one template simply contains

to render the form, and is otherwise exactly the same as the "expanded/flattened" template shown above (had expanded this, saved, & compared the output, too).

This is with Chameleon 2.7.3.