0.10rc1 trackback/Internal Server Error

27 views
Skip to first unread message

cd34

unread,
Mar 20, 2010, 6:50:01 PM3/20/10
to pylons-discuss
I've noticed that since upgrading from 0.9.7 that sometimes rather
than the interactive trackback, I get a white screen with just:

Internal Server Error

This can occur with something as simple as:

${some_undefined_string}

When I upgraded, I used the -t switch, merged the configurations, so,
have I copied too much from one of the files into the 1.0 files?

Mike Orr

unread,
Mar 20, 2010, 10:33:35 PM3/20/10
to pylons-...@googlegroups.com

You get different kinds of Internal Server Errors depending on which
point of the code the exception happens. One shows the error inside an
<h1>; that's Paste's top-level exception handler. The other says
"Internal Server Error" inside a text/plain; that occurs at a really
low (early) point in the code I think, such as an error in
environment.py. When I've gotten that, I think the actual traceback
is printed in the error log.

"${undefined}" would presumably occur inside the Mako template. In
that case, I don't know why the regular error handler wouldn't catch
it. What does 0.9.7 do in that case?

You would have to use "-t pylons" and not just "-t". "-t" alone, if
it's even allowed, would use Paste's default template which is very
different.

It's possible the error could be caused by something incorrectly
merged from the old application structure. Although I'd expect the
application wouldn't work at all in that case. Most of the differences
since 0.9.7 are in environment.py and middleware.py, so you'd expect
that any error there would make the application not start. You could
do the merge again, or create a new default application and compare
your code to it.

Otherwise, what other things trigger this error, and does the error
log say anything?

--
Mike Orr <slugg...@gmail.com>

cd34

unread,
Mar 20, 2010, 10:43:28 PM3/20/10
to pylons-discuss
0.9.7 appeared to catch everything. I've never seen the <h1> or text/
plain error message prior to 1.0rc1

And I did -t pylons based on your initial posting, merged in the .bak
files using diff to identify the sections.

paster console log:

Exception happened during processing of request from ('xx.xx.xx.xx',
64217)
Traceback (most recent call last):
File "/var/www/pylons/lib/python2.5/site-packages/Paste-1.7.2-
py2.5.egg/paste/httpserver.py", line 1062, in
process_request_in_thread
self.finish_request(request, client_address)
File "/usr/lib/python2.5/SocketServer.py", line 254, in
finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/lib/python2.5/SocketServer.py", line 522, in __init__
self.handle()
File "/var/www/pylons/lib/python2.5/site-packages/Paste-1.7.2-
py2.5.egg/paste/httpserver.py", line 436, in handle
BaseHTTPRequestHandler.handle(self)
File "/usr/lib/python2.5/BaseHTTPServer.py", line 316, in handle
self.handle_one_request()
File "/var/www/pylons/lib/python2.5/site-packages/Paste-1.7.2-
py2.5.egg/paste/httpserver.py", line 431, in handle_one_request
self.wsgi_execute()
File "/var/www/pylons/lib/python2.5/site-packages/Paste-1.7.2-
py2.5.egg/paste/httpserver.py", line 287, in wsgi_execute
self.wsgi_start_response)
File "/var/www/pylons/lib/python2.5/site-packages/Paste-1.7.2-
py2.5.egg/paste/cascade.py", line 130, in __call__
return self.apps[-1](environ, start_response)
File "/var/www/pylons/lib/python2.5/site-packages/Paste-1.7.2-
py2.5.egg/paste/registry.py", line 350, in __call__
app_iter = self.application(environ, start_response)
File "/var/www/pylons/lib/python2.5/site-packages/Pylons-0.10rc1-
py2.5.egg/pylons/middleware.py", line 200, in __call__
self.app, environ, catch_exc_info=True)
File "/var/www/pylons/lib/python2.5/site-packages/Pylons-0.10rc1-
py2.5.egg/pylons/util.py", line 91, in call_wsgi_application
app_iter = application(environ, start_response)
File "/var/www/pylons/lib/python2.5/site-packages/WebError-0.10.2-
py2.5.egg/weberror/evalexception.py", line 235, in __call__
return self.respond(environ, start_response)
File "/var/www/pylons/lib/python2.5/site-packages/WebError-0.10.2-
py2.5.egg/weberror/evalexception.py", line 483, in respond
return debug_info.content()
File "/var/www/pylons/lib/python2.5/site-packages/WebError-0.10.2-
py2.5.egg/weberror/evalexception.py", line 545, in content
result = tmpl_formatter(self.exc_value)
File "/var/www/pylons/lib/python2.5/site-packages/Pylons-0.10rc1-
py2.5.egg/pylons/error.py", line 43, in mako_html_data
css=False)
File "/var/www/pylons/lib/python2.5/site-packages/Mako-0.3.1-
py2.5.egg/mako/template.py", line 189, in render
return runtime._render(self, self.callable_, args, data)
File "/var/www/pylons/lib/python2.5/site-packages/Mako-0.3.1-
py2.5.egg/mako/runtime.py", line 402, in _render
_render_context(template, callable_, context, *args, **data)
File "/var/www/pylons/lib/python2.5/site-packages/Mako-0.3.1-
py2.5.egg/mako/runtime.py", line 419, in _render_context
_exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
File "/var/www/pylons/lib/python2.5/site-packages/Mako-0.3.1-
py2.5.egg/mako/runtime.py", line 442, in _exec_template
callable_(context, *args, **kwargs)
File "memory:0xace05cc", line 54, in render_body
File "/var/www/pylons/lib/python2.5/site-packages/Mako-0.3.1-
py2.5.egg/mako/exceptions.py", line 88, in __init__
self.records = self._init(traceback)
File "/var/www/pylons/lib/python2.5/site-packages/Mako-0.3.1-
py2.5.egg/mako/exceptions.py", line 166, in _init
line = line.decode('ascii', 'replace')
AttributeError: 'NoneType' object has no attribute 'decode'


0.9.7 captures it with the :

Error !
NameError: Undefined

5 </%def>
6
7 <%def name="body()">
8 ${unknown}
9
10 test
11 asdf
12
13 </% def>
/var/www/pylons/lib/python2.5/site-packages/Mako-0.2.5-py2.5.egg/mako/
runtime.py, line 128:
raise NameError("Undefined")
/var/www/pylons/lib/python2.5/site-packages/WebHelpers-1.0b1-py2.5.egg/
webhelpers/html/builder.py, line 358:
return literal(cgi_escape(unicode(val), True))
/var/www/pylons/cp/cp/templates/test_flash.mako, line 8:
${unknown}
/var/www/pylons/lib/python2.5/site-packages/Mako-0.2.5-py2.5.egg/mako/
runtime.py, line 255:
return lambda *args, **kwargs:callable_(self.context, *args, **kwargs)
/var/www/pylons/cp/cp/templates/template.mako, line 25:
${self.body()}
/var/www/pylons/lib/python2.5/site-packages/Mako-0.2.5-py2.5.egg/mako/
runtime.py, line 397:
callable_(context, *args, **kwargs)
/var/www/pylons/lib/python2.5/site-packages/Mako-0.2.5-py2.5.egg/mako/
runtime.py, line 405:
result = template.error_handler(context, error)
/var/www/pylons/lib/python2.5/site-packages/Mako-0.2.5-py2.5.egg/mako/
runtime.py, line 381:
_exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
/var/www/pylons/lib/python2.5/site-packages/Mako-0.2.5-py2.5.egg/mako/
runtime.py, line 364:
_render_context(template, callable_, context, *args,
**_kwargs_for_callable(callable_, data))
/var/www/pylons/lib/python2.5/site-packages/Mako-0.2.5-py2.5.egg/mako/
template.py, line 138:
return runtime._render(self, self.callable_, args, data,
as_unicode=True)
/var/www/pylons/lib/python2.5/site-packages/Pylons-0.9.7-py2.5.egg/
pylons/templating.py, line 271:
return literal(template.render_unicode(**globs))
/var/www/pylons/lib/python2.5/site-packages/Pylons-0.9.7-py2.5.egg/
pylons/templating.py, line 249:
return render_func()
/var/www/pylons/lib/python2.5/site-packages/Pylons-0.9.7-py2.5.egg/
pylons/templating.py, line 274:
cache_type=cache_type, cache_expire=cache_expire)
/var/www/pylons/cp/cp/controllers/test.py, line 73:
return render('/test_flash.mako')
/var/www/pylons/lib/python2.5/site-packages/Pylons-0.9.7-py2.5.egg/
pylons/controllers/core.py, line 60:
return func(**args)
/var/www/pylons/lib/python2.5/site-packages/Pylons-0.9.7-py2.5.egg/
pylons/controllers/core.py, line 107:
result = self._perform_call(func, args)
/var/www/pylons/lib/python2.5/site-packages/Pylons-0.9.7-py2.5.egg/
pylons/controllers/core.py, line 172:
response = self._inspect_call(func)
/var/www/pylons/lib/python2.5/site-packages/Pylons-0.9.7-py2.5.egg/
pylons/controllers/core.py, line 221:
response = self._dispatch_call()
/var/www/pylons/cp/cp/lib/base.py, line 18:
return WSGIController.__call__(self, environ, start_response)
/var/www/pylons/lib/python2.5/site-packages/Pylons-0.9.7-py2.5.egg/
pylons/wsgiapp.py, line 324:
return controller(environ, start_response)
/var/www/pylons/lib/python2.5/site-packages/Pylons-0.9.7-py2.5.egg/
pylons/wsgiapp.py, line 125:
response = self.dispatch(controller, environ, start_response)
/var/www/pylons/lib/python2.5/site-packages/Routes-1.11-py2.5.egg/
routes/middleware.py, line 130:
response = self.app(environ, start_response)
/var/www/pylons/lib/python2.5/site-packages/Beaker-1.4.2-py2.5.egg/
beaker/middleware.py, line 152:
return self.wrap_app(environ, session_start_response)
/var/www/pylons/lib/python2.5/site-packages/Beaker-1.4.2-py2.5.egg/
beaker/middleware.py, line 73:
return self.app(environ, start_response)
build/bdist.linux-i686/egg/webob/__init__.py, line 1293:
None
build/bdist.linux-i686/egg/webob/__init__.py, line 1325:
None
/var/www/pylons/lib/python2.5/site-packages/ToscaWidgets-0.9.8-
py2.5.egg/tw/core/resource_injector.py, line 68:
resp = req.get_response(app)
build/bdist.linux-i686/egg/webob/__init__.py, line 1293:
None
build/bdist.linux-i686/egg/webob/__init__.py, line 1325:
None
/var/www/pylons/lib/python2.5/site-packages/ToscaWidgets-0.9.8-
py2.5.egg/tw/core/middleware.py, line 68:
resp = req.get_response(self.application)
/var/www/pylons/lib/python2.5/site-packages/ToscaWidgets-0.9.8-
py2.5.egg/tw/core/middleware.py, line 43:
return self.wsgi_app(environ, start_response)
/var/www/pylons/lib/python2.5/site-packages/AuthKit-0.4.5-py2.5.egg/
authkit/authenticate/__init__.py, line 425:
return self.application(environ, start_response)
/var/www/pylons/lib/python2.5/site-packages/AuthKit-0.4.5-py2.5.egg/
authkit/authenticate/__init__.py, line 321:
return self.app(environ, start_response)
/var/www/pylons/lib/python2.5/site-packages/AuthKit-0.4.5-py2.5.egg/
authkit/authenticate/__init__.py, line 344:
return self.app(environ, start_response)
/var/www/pylons/lib/python2.5/site-packages/AuthKit-0.4.5-py2.5.egg/
authkit/authenticate/__init__.py, line 176:
return self.app(environ, start_response)
/var/www/pylons/lib/python2.5/site-packages/AuthKit-0.4.5-py2.5.egg/
authkit/authenticate/multi.py, line 55:
return self.default(environ, find)
/var/www/pylons/lib/python2.5/site-packages/AuthKit-0.4.5-py2.5.egg/
authkit/authenticate/multi.py, line 87:
app_iter = app(environ, start_response)
/var/www/pylons/lib/python2.5/site-packages/AuthKit-0.4.5-py2.5.egg/
authkit/authenticate/cookie.py, line 480:
return self.app(environ, cookie_setting_start_response)
/var/www/pylons/lib/python2.5/site-packages/AuthKit-0.4.5-py2.5.egg/
authkit/authenticate/__init__.py, line 331:
return self.app(environ, start_response)
/var/www/pylons/lib/python2.5/site-packages/SQLAlchemyManager-0.1.0-
py2.5.egg/sqlalchemymanager/__init__.py, line 84:
return self.app(environ, start_response)
/var/www/pylons/lib/python2.5/site-packages/WebError-0.10.1-py2.5.egg/
weberror/evalexception.py, line 431:
app_iter = self.application(environ, detect_start_response)

So, the behavior did change.

Mike Orr

unread,
Mar 21, 2010, 1:00:34 PM3/21/10
to pylons-...@googlegroups.com, Ben Bangert, Michael Bayer, Ian Bicking
The tracebacks are quite different. Cc'ing Ben, MikeB, and IanB to see
if they can see the problem. The second one (Pylons 0.9.7, which is
correct) is a Mako web traceback so the direction is reversed
(innermost on top), and several outer layers appear to be suppressed
(outermost layer is WebError).

The first one (Pylons 0.10rc1) is a console traceback: the web
traceback could not be produced for some reason. It shows a different
path from WebError.evalexception through the 'tmpl_formatter'
variable, which goes into Mako again and then bombs on a 'line'
variable in mako/exceptions.py, which is supposed to be a string but
is None. I don't know if that's related to "${undefined}" in the
original template or not.

If you're familiar with the Python debugger, I'd be interested to see
the value of 'line' in mako/exceptions.py line 166, and
'tmpl_formatter' and 'self.exc_value' in weberror/evalexception.py
line 545, as well as the value of 'template' in mako/runtime.py line
402. Those might give a clue as to why it's doing that. I suspect it
was trying to format another exception when this exception occurred
and obliterated it.

I'm not sure if the debugger works with a Pylons application. If you
can't get it to, you can email me a tarball of the app and I'll see if
I can get anything out of it.

> --
> You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
> To post to this group, send email to pylons-...@googlegroups.com.
> To unsubscribe from this group, send email to pylons-discus...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
>
>

--
Mike Orr <slugg...@gmail.com>

cd34

unread,
Mar 21, 2010, 1:21:58 PM3/21/10
to pylons-discuss
At this point, it appears to be something I've done wrong in the
upgrade as a freshly installed 1.0rc1 displays the trackback properly.

I'll debug this a bit further.

cd34

unread,
Mar 22, 2010, 1:46:01 AM3/22/10
to pylons-discuss
Something else is considerably broken with my upgraded installation.
webhelpers pager() on pages that were previously working and have been
untouched are also throwing the 'Internal Server Error'

I think something related to the change in the config handling
probably broke in my installation. I'm going to create a new
virtualenv, fresh install, bring in my code as if it was fresh, then
figure out what the difference is between the two virtualenvs. I
glanced through all of the .bak files again but didn't really see
anything suspect.

Mike Orr

unread,
Mar 22, 2010, 2:53:38 PM3/22/10
to pylons-...@googlegroups.com
On Sun, Mar 21, 2010 at 10:46 PM, cd34 <mcd...@gmail.com> wrote:
> Something else is considerably broken with my upgraded installation.
> webhelpers pager() on pages that were previously working and have been
> untouched are also throwing the 'Internal Server Error'

Again, please post the traceback.

If it says anything about 'routes.url_for()', it may be related to
another issue, it may be related to another issue we're dealing with.
In short, I'm checking whether Paginate needs to be updated to
accommodate the new version of Routes and Pylons, and whether it's
necessary to do this now or after 1.0.

(In detail, Paginate uses url_for(), which depends on a singleton in
Routes. Something in Routes 1.12 threw off one of the
webhelpers.paginate unittests. Meanwhile, Pylons now has an option to
not use the singleton. (Not using the singleton means url_for() won't
work; which is why we're migrating to pylons.url. But Paginate
doesn't have access to pylons.url.) Changing Paginate to not use the
singleton would require the user to pass in a callback function to
generate a URL to the other pages. So I'm checking whether it's
necessary to do this for WebHelpers 1.0 or whether it will affect only
future apps that use this option.)

--
Mike Orr <slugg...@gmail.com>

cd34

unread,
Mar 22, 2010, 3:26:27 PM3/22/10
to pylons-discuss
Right now, the issue appears related to ToscaWidgets. As soon as I
put ToscaWidgets into my test environment, the undefined variable
changes from the mako traceback to the 'Internal Server Error'

Here's the error prior to ToscaWidgets being installed:

Error !
NameError: Undefined

1 asdf
2 ${asdf}
3
/var/www/pylons/lib/python2.5/site-packages/Mako-0.3.2-py2.5.egg/mako/
runtime.py, line 135:
raise NameError("Undefined")
/var/www/pylons/lib/python2.5/site-packages/WebHelpers-1.0b5-py2.5.egg/
webhelpers/html/builder.py, line 412:
return literal(cgi_escape(unicode(val), True))
/var/www/pylons/cp/cp/templates/test_index.mako, line 2:
${asdf}
/var/www/pylons/lib/python2.5/site-packages/Mako-0.3.2-py2.5.egg/mako/
runtime.py, line 450:
callable_(context, *args, **kwargs)
/var/www/pylons/lib/python2.5/site-packages/Mako-0.3.2-py2.5.egg/mako/
runtime.py, line 462:
result = template.error_handler(context, error)
/var/www/pylons/lib/python2.5/site-packages/Mako-0.3.2-py2.5.egg/mako/
runtime.py, line 452:
_render_error(template, context, e)
/var/www/pylons/lib/python2.5/site-packages/Mako-0.3.2-py2.5.egg/mako/
runtime.py, line 434:
_exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
/var/www/pylons/lib/python2.5/site-packages/Mako-0.3.2-py2.5.egg/mako/
runtime.py, line 403:


_render_context(template, callable_, context, *args,
**_kwargs_for_callable(callable_, data))

/var/www/pylons/lib/python2.5/site-packages/Mako-0.3.2-py2.5.egg/mako/
template.py, line 198:
as_unicode=True)
/var/www/pylons/lib/python2.5/site-packages/Pylons-0.10rc1-py2.5.egg/


pylons/templating.py, line 271:
return literal(template.render_unicode(**globs))

/var/www/pylons/lib/python2.5/site-packages/Pylons-0.10rc1-py2.5.egg/


pylons/templating.py, line 249:
return render_func()

/var/www/pylons/lib/python2.5/site-packages/Pylons-0.10rc1-py2.5.egg/


pylons/templating.py, line 274:
cache_type=cache_type, cache_expire=cache_expire)

/var/www/pylons/cp/cp/controllers/test.py, line 20:
return render('/test_index.mako')
/var/www/pylons/lib/python2.5/site-packages/Pylons-0.10rc1-py2.5.egg/


pylons/controllers/core.py, line 60:
return func(**args)

/var/www/pylons/lib/python2.5/site-packages/Pylons-0.10rc1-py2.5.egg/
pylons/controllers/core.py, line 108:
result = self._perform_call(func, args)
/var/www/pylons/lib/python2.5/site-packages/Pylons-0.10rc1-py2.5.egg/
pylons/controllers/core.py, line 176:
response = self._inspect_call(func)
/var/www/pylons/lib/python2.5/site-packages/Pylons-0.10rc1-py2.5.egg/
pylons/controllers/core.py, line 225:


response = self._dispatch_call()
/var/www/pylons/cp/cp/lib/base.py, line 18:
return WSGIController.__call__(self, environ, start_response)

/var/www/pylons/lib/python2.5/site-packages/Pylons-0.10rc1-py2.5.egg/
pylons/wsgiapp.py, line 327:
return controller(environ, start_response)
/var/www/pylons/lib/python2.5/site-packages/Pylons-0.10rc1-py2.5.egg/
pylons/wsgiapp.py, line 124:


response = self.dispatch(controller, environ, start_response)

/var/www/pylons/lib/python2.5/site-packages/Routes-1.12.1-py2.5.egg/
routes/middleware.py, line 131:
response = self.app(environ, start_response)
/var/www/pylons/lib/python2.5/site-packages/Beaker-1.5.3-py2.5.egg/


beaker/middleware.py, line 152:
return self.wrap_app(environ, session_start_response)

/var/www/pylons/lib/python2.5/site-packages/WebError-0.10.2-py2.5.egg/


weberror/evalexception.py, line 431:
app_iter = self.application(environ, detect_start_response)

Pylons version 0.10rc1

Here's the error from the console after ToscaWidgets is enabled by
adding the following lines to config/middleware.py

import tw.api as twa

# CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares)
app = twa.make_middleware(app, {
'toscawidgets.framework': 'pylons',
'toscawidgets.framework.default_view': 'mako',
})

serving on 0.0.0.0:8080 view at http://127.0.0.1:8080
Debug at: http://pch1.mia.colo-cation.com:8080/_debug/view/1269285807
----------------------------------------
Exception happened during processing of request from ('72.153.151.78',
58225)

File "/var/www/pylons/lib/python2.5/site-packages/Mako-0.3.2-


py2.5.egg/mako/template.py", line 189, in render
return runtime._render(self, self.callable_, args, data)

File "/var/www/pylons/lib/python2.5/site-packages/Mako-0.3.2-
py2.5.egg/mako/runtime.py", line 403, in _render
_render_context(template, callable_, context, *args,
**_kwargs_for_callable(callable_, data))
File "/var/www/pylons/lib/python2.5/site-packages/Mako-0.3.2-
py2.5.egg/mako/runtime.py", line 434, in _render_context
_exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
File "/var/www/pylons/lib/python2.5/site-packages/Mako-0.3.2-
py2.5.egg/mako/runtime.py", line 457, in _exec_template
callable_(context, *args, **kwargs)
File "memory:0xb66726ccL", line 54, in render_body
File "/var/www/pylons/lib/python2.5/site-packages/Mako-0.3.2-


py2.5.egg/mako/exceptions.py", line 88, in __init__
self.records = self._init(traceback)

File "/var/www/pylons/lib/python2.5/site-packages/Mako-0.3.2-


py2.5.egg/mako/exceptions.py", line 166, in _init
line = line.decode('ascii', 'replace')
AttributeError: 'NoneType' object has no attribute 'decode'

----------------------------------------

So, it appears to be related to ToscaWidgets.

Beaker-1.5.3-py2.5.egg Pylons-0.10rc1-py2.5.egg
decorator-3.1.2-py2.5.egg Routes-1.12.1-py2.5.egg
easy-install.pth setuptools-0.6c11-py2.5.egg
Mako-0.3.2-py2.5.egg setuptools.pth
nose-0.11.3-py2.5.egg Tempita-0.4-py2.5.egg
Paste-1.7.2-py2.5.egg ToscaWidgets-0.9.9-py2.5.egg
PasteDeploy-1.3.3-py2.5.egg tw.forms-0.9.9-py2.5.egg
PasteScript-1.7.3-py2.5.egg WebError-0.10.2-py2.5.egg
pip-0.6.3-py2.5.egg WebHelpers-1.0b5-py2.5.egg
Pygments-1.3.1-py2.5.egg WebTest-1.2-py2.5.egg

I'll post this over in their mailing list to see if they have any
thoughts.

cd34

unread,
Mar 22, 2010, 4:28:13 PM3/22/10
to pylons-discuss
My error. I missed the note regarding ToscaWidgets and 0.10rc1.

http://toscawidgets.org/trac/tw/ticket/48 is the ticket with Graham
Higgins's proposed patch.

cd34

unread,
Mar 30, 2010, 6:01:13 PM3/30/10
to pylons-discuss
updated this in http://groups.google.com/group/toscawidgets-discuss/t/abbf98633fd3c89c

I've taken Graham Higgins's patch, modified it slightly to do the
version math and to handle the 0.10rc1 and 1.0rc1 version identifiers
with a hack. Toscawidgets loads in both 0.10rc1 and 1.0rc1 and does
handle form entry.

It still has an issue with ${asdf} when asdf is not defined, but I'm
not familiar enough with Pylons internals to debug it much further
without some guidance.

kazin

unread,
Apr 15, 2010, 4:58:25 PM4/15/10
to pylons-discuss
Just chiming in, I too have the same issue with ${asdf} giving me an
internal server error, even after removing ToscaWidgets (and
AuthKit). I backed out most of the changes I have made from my fresh
install of 1.0rc1 but still cant find the culprit that introduced this
issue

Ben Bangert

unread,
Apr 15, 2010, 5:02:52 PM4/15/10
to pylons-...@googlegroups.com

Using a name that's not defined in a Mako template should *always* throw an error. What is happening when you use an undefined variable, and what are you expecting?

Cheers,
Ben

cd34

unread,
Apr 15, 2010, 6:56:58 PM4/15/10
to pylons-discuss
On Apr 15, 5:02 pm, Ben Bangert <b...@groovie.org> wrote:
> Using a name that's not defined in a Mako template should *always* throw an error. What is happening when you use an undefined variable, and what are you expecting?

0.9.7 returned a mako template error in the browser which allowed you
to see the context. 0.10rc1 and 1.0rc1 both return Internal Server
Error in the browser, and you have to revert back to the console
trackback to see what occurred. For me, it is exclusive to
ToscaWidgets - disabling it returns the previous behavior.

Ben Bangert

unread,
Apr 15, 2010, 7:36:15 PM4/15/10
to pylons-...@googlegroups.com
On Apr 15, 2010, at 3:56 PM, cd34 wrote:

> On Apr 15, 5:02 pm, Ben Bangert <b...@groovie.org> wrote:
>> Using a name that's not defined in a Mako template should *always* throw an error. What is happening when you use an undefined variable, and what are you expecting?
>
> 0.9.7 returned a mako template error in the browser which allowed you
> to see the context. 0.10rc1 and 1.0rc1 both return Internal Server
> Error in the browser, and you have to revert back to the console
> trackback to see what occurred. For me, it is exclusive to
> ToscaWidgets - disabling it returns the previous behavior.

Ah, yes, there was a ToscaWidgets bug which masked the proper error handling. I mean in my existing projects I've moved to 1.0rc1, I haven't seen this issue. Were you saying that this was happening with a non-toscawidgets project using 0.10/1.0?

- Ben

cd34

unread,
Apr 15, 2010, 8:54:03 PM4/15/10
to pylons-discuss
On Apr 15, 7:36 pm, Ben Bangert <b...@groovie.org> wrote:
> Ah, yes, there was a ToscaWidgets bug which masked the proper error handling. I mean in my existing projects I've moved to 1.0rc1, I haven't seen this issue. Were you saying that this was happening with a non-toscawidgets project using 0.10/1.0?

I have run into two issues. ToscaWidgets (which is still broken with
0.10/1.0, but, less broken with the pylonshf.diff file that Diez
Roggisch modified from Graham Higgins's patch. A minor issue with
paginate related to webhelpers (which has since been fixed).

Disabling ToscaWidgets restores the expected behavior with ${asdf}
inserted into a template for me. I believe kazin is saying that
disabling ToscaWidgets still results in him seeing the console
traceback rather than the webpage traceback.

kazin

unread,
Apr 15, 2010, 9:07:27 PM4/15/10
to pylons-discuss
> Ah, yes, there was a ToscaWidgets bug which masked the proper error handling. I mean in my existing projects I've moved to 1.0rc1, I haven't seen this issue. Were you saying that this was happening with a non-toscawidgets project using 0.10/1.0?

Yes. Sorry for the imprecision. In 1.0rc1 I am getting an Internal
Server error on undefined Mako name instead of seeing the expected
mako template error in the browser. Controller errors such as 'name
not defined' correctly produce the WebError Traceback, so this seems
limited to Mako errors.

This is a new project on 1.0rc1, I have AuthKit in the middleware (and
am using FormAlchemy). I had installed tw.Forms but abandoned it when
it failed to work out of the box (I removed the middleware and the
import from config/middleware.py).

A stack trace follows below in case it helps.

--Rich


Traceback (most recent call last):
File "/Users/kazin/env/vng/lib/python2.6/site-packages/paste/
httpserver.py", line 1068, in process_request_in_thread
self.finish_request(request, client_address)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/
lib/python2.6/SocketServer.py", line 320, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/
lib/python2.6/SocketServer.py", line 615, in __init__
self.handle()
File "/Users/kazin/env/vng/lib/python2.6/site-packages/paste/
httpserver.py", line 442, in handle
BaseHTTPRequestHandler.handle(self)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/
lib/python2.6/BaseHTTPServer.py", line 329, in handle
self.handle_one_request()
File "/Users/kazin/env/vng/lib/python2.6/site-packages/paste/
httpserver.py", line 437, in handle_one_request
self.wsgi_execute()
File "/Users/kazin/env/vng/lib/python2.6/site-packages/paste/
httpserver.py", line 287, in wsgi_execute
self.wsgi_start_response)
File "/Users/kazin/env/vng/lib/python2.6/site-packages/paste/
cascade.py", line 130, in __call__
return self.apps[-1](environ, start_response)
File "/Users/kazin/env/vng/lib/python2.6/site-packages/paste/
registry.py", line 375, in __call__
app_iter = self.application(environ, start_response)
File "/Users/kazin/env/vng/lib/python2.6/site-packages/Pylons-1.0rc1-
py2.6.egg/pylons/middleware.py", line 150, in __call__
self.app, environ, catch_exc_info=True)
File "/Users/kazin/env/vng/lib/python2.6/site-packages/Pylons-1.0rc1-
py2.6.egg/pylons/util.py", line 48, in call_wsgi_application
app_iter = application(environ, start_response)
File "/Users/kazin/env/vng/lib/python2.6/site-packages/weberror/
evalexception.py", line 235, in __call__
return self.respond(environ, start_response)
File "/Users/kazin/env/vng/lib/python2.6/site-packages/weberror/
evalexception.py", line 483, in respond
return debug_info.content()
File "/Users/kazin/env/vng/lib/python2.6/site-packages/weberror/
evalexception.py", line 545, in content
result = tmpl_formatter(self.exc_value)
File "/Users/kazin/env/vng/lib/python2.6/site-packages/Pylons-1.0rc1-
py2.6.egg/pylons/error.py", line 41, in mako_html_data
css=False)
File "/Users/kazin/env/vng/lib/python2.6/site-packages/mako/
template.py", line 189, in render
return runtime._render(self, self.callable_, args, data)
File "/Users/kazin/env/vng/lib/python2.6/site-packages/mako/
runtime.py", line 403, in _render
_render_context(template, callable_, context, *args,
**_kwargs_for_callable(callable_, data))
File "/Users/kazin/env/vng/lib/python2.6/site-packages/mako/
runtime.py", line 434, in _render_context
_exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
File "/Users/kazin/env/vng/lib/python2.6/site-packages/mako/
runtime.py", line 457, in _exec_template
callable_(context, *args, **kwargs)
File "memory:0x103696350", line 54, in render_body
File "/Users/kazin/env/vng/lib/python2.6/site-packages/mako/
exceptions.py", line 88, in __init__
self.records = self._init(traceback)
File "/Users/kazin/env/vng/lib/python2.6/site-packages/mako/
exceptions.py", line 166, in _init
line = line.decode('ascii', 'replace')
AttributeError: 'NoneType' object has no attribute 'decode'

Mike Orr

unread,
Apr 15, 2010, 11:47:00 PM4/15/10
to pylons-...@googlegroups.com
On Thu, Apr 15, 2010 at 6:07 PM, kazin <rich...@gmail.com> wrote:
> This is a new project on 1.0rc1, I have AuthKit in the middleware (and
> am using FormAlchemy).

Could you try commenting out AuthKit and seeing if the error changes?
I doubt it will, but that would rule out AuthKit as a contributor.

--
Mike Orr <slugg...@gmail.com>

Jack Tihon

unread,
Apr 16, 2010, 12:38:14 AM4/16/10
to pylons-...@googlegroups.com
I was getting the same thing when I was trying to reference "h.url()" which no longer exists.

I was getting a non-helpful backtrace like above.

-jack

P.S.: Time to update the docs here as well since h.url() is now incorrect.

Mike Orr

unread,
Apr 16, 2010, 5:37:50 AM4/16/10
to pylons-...@googlegroups.com
On Thu, Apr 15, 2010 at 9:38 PM, Jack Tihon <konoh...@gmail.com> wrote:
> I was getting the same thing when I was trying to reference "h.url()" which no longer exists.

It's not 'h.url' unless you import it to helpers.py that way. It's
just 'url' in templates. In controllers and other modules it's 'from
pylons import url'.

> P.S.: Time to update the docs here as well since h.url() is now incorrect.

Which docs are out of date? the unfinished 1.0 docs are here:
http://pylonshq.com/docs/en/1.0/ . The Pylons book can't be changed,
although I've asked James to put an update page on the website. There
are no doubt lots of url_for's in the wiki, but those will take time
to hunt down and eradicate.

Note that WebHelpers Paginate still uses url_for so it's incompatible
with 1.0 -- or at least Page.pager() is. I'm waiting for a patch from
Christoph to fix that, but it will require a new function argument to
generate the page URLs. More info when it's ready.

--
Mike Orr <slugg...@gmail.com>

Jack Tihon

unread,
Apr 16, 2010, 12:32:36 PM4/16/10
to pylons-...@googlegroups.com

On Apr 16, 2010, at 2:37 AM, Mike Orr wrote:

On Thu, Apr 15, 2010 at 9:38 PM, Jack Tihon <konoh...@gmail.com> wrote:
I was getting the same thing when I was trying to reference "h.url()" which no longer exists.


It's not 'h.url' unless you import it to helpers.py that way.  It's
just 'url' in templates. In controllers and other modules it's 'from
pylons import url'.

Yeah, I was just following the tutorial and getting 'Internal Server Error' until I realized that things have moved around a bit.

P.S.: Time to update the docs here as well since h.url() is now incorrect.

Which docs are out of date? the unfinished 1.0 docs are here:
http://pylonshq.com/docs/en/1.0/ . The Pylons book can't be changed,
although I've asked James to put an update page on the website. There
are no doubt lots of url_for's in the wiki, but those will take time
to hunt down and eradicate.

I was walking through this which references h.url()



Note that WebHelpers Paginate still uses url_for so it's incompatible
with 1.0 -- or at least Page.pager() is. I'm waiting for a patch from
Christoph to fix that, but it will require a new function argument to
generate the page URLs. More info when it's ready.


Thanks,

-jack

--
Mike Orr <slugg...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
To post to this group, send email to pylons-...@googlegroups.com.
To unsubscribe from this group, send email to pylons-discus...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.


kazin

unread,
Apr 16, 2010, 12:42:42 PM4/16/10
to pylons-discuss
> Could you try commenting out AuthKit and seeing if the error changes?
> I doubt it will, but that would rule out AuthKit as a contributor.

Problem still exists when I removed AuthKit from the middleware. I
also tried recreating the virtualenv but that didn't seem to affect
things.

I'm going to go try recreating the whole app and copying over my
changes to see if I can track where it goes astray.

Thanks!

-Rich

Mike Orr

unread,
Apr 16, 2010, 12:54:39 PM4/16/10
to pylons-...@googlegroups.com, Ben Bangert
On Fri, Apr 16, 2010 at 9:32 AM, Jack Tihon <konoh...@gmail.com> wrote:
> Yeah, I was just following the tutorial and getting

Which tutorial are you following?

> I was walking through this which references h.url()
> http://pylonshq.com/docs/en/1.0/forms/#the-basics

OK, that's a mistake in the doc.

kazin

unread,
Apr 16, 2010, 1:22:39 PM4/16/10
to pylons-discuss
> I'm going to go try recreating the whole app and copying over my
> changes to see if I can track where it goes astray.

My problem was caused by me adding a @nocache decorator to the
BaseController's __call__method. As soon as that was removed,
Template errors started appearing again.

I must have screwed up when I tested removing it before.Sorry for the
trouble, and thanks for the help!

--Rich

Mike Orr

unread,
Apr 16, 2010, 2:06:55 PM4/16/10
to pylons-...@googlegroups.com
On Fri, Apr 16, 2010 at 10:22 AM, kazin <rich...@gmail.com> wrote:
>> I'm going to go try recreating the whole app and copying over my
>> changes to see if I can track where it goes astray.
>
> My problem was caused by me adding a @nocache decorator to the
> BaseController's __call__method.  As soon as that was removed,
> Template errors started appearing again.
>
> I must have screwed up when I tested removing it before.Sorry for the
> trouble, and thanks for the help!

Still, does this mean there's a bug? Shouldn't errors pass through
@nocache cleanly?

I guess it depends on whether it's reasonable to put @nocache on the
base controller, and that I don't know because I don't use it. If
somebody thinks it should work, and can confirm it's not behaving
properly in the case of missing template variables, please open a bug
ticket for it.

--
Mike Orr <slugg...@gmail.com>

Alexandre Bourget

unread,
Apr 17, 2010, 12:26:20 PM4/17/10
to pylons-...@googlegroups.com
Same problem here.

Seems to me it's a Mako related exception handling bug.  It stalls in it's mako/exception.py file when a `line` is None..

Was this solved or reported to the Mako guys ?

thanks

Alexandre

Alexandre Bourget

unread,
Apr 17, 2010, 4:30:06 PM4/17/10
to pylons-...@googlegroups.com
Found the bug.

It's in Mako, dealing with a traceback that contains a closure (any decorated function).

When it lists the backtrace, like:

 ('/home/wacky/build/Vigilia/env/lib/python2.6/site-packages/pylons/controllers/core.py',
  105,
  '_inspect_call',
  'result = self._perform_call(func, args)'),
 ('/home/wacky/build/Vigilia/env/lib/python2.6/site-packages/pylons/controllers/core.py',
  57,
  '_perform_call',
  'return func(**args)'),
 ('<string>', 2, 'edit_album', None),
 ('/home/wacky/build/Vigilia/vigilia/lib/base.py',
  88,
  'wrapper',
  'return func(self, *args, **kwargs)'),


notice the <string>, 'edit_album', and None object.  This None object is the cause. It should be converted to string, or Mako should know how to deal with it.

We get a None there when the function is a closure, or a returned function that dynamically generated, which is the case with most decorators.

The solution is a two-liner:

diff -r d51e9106731b mako/exceptions.py
--- a/mako/exceptions.py Tue Apr 13 10:07:04 2010 -0400
+++ b/mako/exceptions.py Sat Apr 17 16:28:52 2010 -0400
@@ -152,6 +152,8 @@
         rawrecords = traceback.extract_tb(trcback)
         new_trcback = []
         for filename, lineno, function, line in rawrecords:
+            if not line:
+                line = ''
             try:
                 (line_map, template_lines) = mods[filename]
             except KeyError:

Just hope someone from the Mako team sees this.

Hope this helps,


Alexandre Bourget
Savoir-faire Linux inc.

chris...@gmail.com

unread,
Apr 21, 2010, 8:35:18 PM4/21/10
to pylons-discuss

cheap workaround is to replace

line = line.decode('ascii','replace')

to:

if line:
line = line.decode('ascii','replace')

in the offending file (line 166 in mako/exceptions.py for Mako-0.3.2)

errors then seem to correctly propagate up the stack.

On Apr 17, 9:26 am, Alexandre Bourget <a...@bourget.cc> wrote:
> Same problem here.
>
> Seems to me it's a Mako related exception handling bug.  It stalls in it's
> mako/exception.py file when a `line` is None..
>
> Was this solved or reported to the Mako guys ?
>
> thanks
>
> Alexandre
>
>
>
> On Fri, Apr 16, 2010 at 2:06 PM, Mike Orr <sluggos...@gmail.com> wrote:
> > On Fri, Apr 16, 2010 at 10:22 AM, kazin <richka...@gmail.com> wrote:
> > >> I'm going to go try recreating the whole app and copying over my
> > >> changes to see if I can track where it goes astray.
>
> > > My problem was caused by me adding a @nocache decorator to the
> > > BaseController's __call__method.  As soon as that was removed,
> > > Template errors started appearing again.
>
> > > I must have screwed up when I tested removing it before.Sorry for the
> > > trouble, and thanks for the help!
>
> > Still, does this mean there's a bug? Shouldn't errors pass through
> > @nocache cleanly?
>
> > I guess it depends on whether it's reasonable to put @nocache on the
> > base controller, and that I don't know because I don't use it. If
> > somebody thinks it should work, and can confirm it's not behaving
> > properly in the case of missing template variables, please open a bug
> > ticket for it.
>
> > --
> > Mike Orr <sluggos...@gmail.com>
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "pylons-discuss" group.
> > To post to this group, send email to pylons-...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > pylons-discus...@googlegroups.com<pylons-discuss%2Bunsu...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/pylons-discuss?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
> To post to this group, send email to pylons-...@googlegroups.com.
> To unsubscribe from this group, send email to pylons-discus...@googlegroups.com.
> For more options, visit this group athttp://groups.google.com/group/pylons-discuss?hl=en.

cd34

unread,
Apr 22, 2010, 7:06:58 PM4/22/10
to pylons-discuss
It has been fixed:

http://groups.google.com/group/mako-discuss/msg/f06184b0ee507c63

I just pulled the latest tip and it works as expected.
Reply all
Reply to author
Forward
0 new messages