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?
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>
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.
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>
I'll debug this a bit further.
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.
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>
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.
http://toscawidgets.org/trac/tw/ticket/48 is the ticket with Graham
Higgins's proposed patch.
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.
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
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>
--
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.