[Mako] In Pylons 1.0rc1/0.10rc1, Mako generates an Internal Server Error under odd circumstances

17 views
Skip to first unread message

cd34

unread,
Apr 22, 2010, 6:23:57 PM4/22/10
to Mako Templates for Python
In this thread, http://groups.google.com/group/pylons-discuss/t/ede16f830f41fa1
I raised the issue with ToscaWidgets and the handling of an undefined
variable of ${asdf} which would return Internal Server Error and
Pylons would generate the error trackback on the console.

While I had assumed it was ToscaWidgets, and a patch was created to
deal with the removal of buffet from Pylons 1.0, the error persisted
for a few other people. The issue also appeared with the @nocache
decorator for another person.

http://groups.google.com/group/pylons-discuss/msg/672ea3c58291ec25
and
http://groups.google.com/group/pylons-discuss/msg/80bbab0036399e80

propose workarounds. The first post actually discovers that the error
is:

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.

I have tested both patches and both result in the mako trackback being
displayed in the browser as it is expected. Both suggested solutions
take different approaches, but, the issue appears to be identified.

http://groups.google.com/group/toscawidgets-discuss/msg/f40676043e4134e0
contains the exact instructions used to reproduce the problem with
ToscaWidgets.

http://groups.google.com/group/toscawidgets-discuss/msg/e35d625097d71c04
includes a sample project with the bare minimum and the modified
pylonshf.py file required for ToscaWidgets to work in 1.0rc1/0.10rc1.

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

Michael Bayer

unread,
Apr 22, 2010, 6:36:40 PM4/22/10
to mako-d...@googlegroups.com

this issue:

> http://groups.google.com/group/pylons-discuss/msg/80bbab0036399e80

has been fixed. Have you tried the latest tip?

cd34

unread,
Apr 22, 2010, 6:44:58 PM4/22/10
to Mako Templates for Python
easy_install -U http://svn.makotemplates.org/mako/trunk

I tried this, it upgraded me to Mako==0.3.2dev-r532

${asdf} in my template results in the same console trackback and
'Internal Server Error' on the webpage

File "/var/www/pylons/lib/python2.5/site-packages/Mako-0.3.2dev_r532-
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.2dev_r532-
py2.5.egg/mako/exceptions.py", line 166, in _init
line = line.decode('ascii', 'replace')
AttributeError: 'NoneType' object has no attribute 'decode'

Michael Bayer

unread,
Apr 22, 2010, 6:55:23 PM4/22/10
to mako-d...@googlegroups.com
cd34 wrote:
> easy_install -U http://svn.makotemplates.org/mako/trunk

sorry, that's not correct. we are no longer on SVN and the trunk has a
large file
http://svn.makotemplates.org/mako/trunk/README_MOVED_TO_MERCURIAL
describing this.

the tip is available via "hg clone http://hg.makotemplates.org/mako" which
is on the front page of the wiki.

cd34

unread,
Apr 22, 2010, 7:03:58 PM4/22/10
to Mako Templates for Python
http://www.makotemplates.org/download.html

is what I followed from the Download link on the front page of the
site.

Will give this a try in a minute. Sorry to be a nuisance.

cd34

unread,
Apr 22, 2010, 7:08:15 PM4/22/10
to Mako Templates for Python
With the latest tip, it works properly.

Thank you.

Michael Bayer

unread,
Apr 23, 2010, 12:23:57 AM4/23/10
to mako-d...@googlegroups.com
wow I missed that, it will be changed immediately.

Michael Bayer

unread,
Apr 23, 2010, 12:28:49 AM4/23/10
to mako-d...@googlegroups.com
all mentions of SVN are entirely removed from the site, you have my apologies for the misleading text. I will now remove it from the pypi listing.

cd34

unread,
Apr 23, 2010, 3:47:05 PM4/23/10
to Mako Templates for Python
On Apr 23, 12:28 am, Michael Bayer <mike...@zzzcomputing.com> wrote:
> all mentions of SVN are entirely removed from the site, you have my apologies for the misleading text.   I will now remove it from the pypi listing.

It happens, no big deal. I only wish I had gone with my gut and
posted it here long ago when I first hit it. Because I only saw the
issue with ToscaWidgets/Pylons after Pylons removed buffet rendering,
I didn't think it was a Mako issue.

All's well that ends well.

Marcin Kasperski

unread,
May 29, 2010, 8:11:55 AM5/29/10
to mako-d...@googlegroups.com
> ${asdf} in my template results in the same console trackback and
> 'Internal Server Error' on the webpage
>
> File "/var/www/pylons/lib/python2.5/site-packages/Mako-0.3.2dev_r532-
> 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.2dev_r532-
> py2.5.egg/mako/exceptions.py", line 166, in _init
> line = line.decode('ascii', 'replace')
> AttributeError: 'NoneType' object has no attribute 'decode'

I also faced this error (while migrating to pylons10)

Patching it is not a big deal, but maybe it deserves mako release?

Michael Bayer

unread,
May 29, 2010, 2:48:21 PM5/29/10
to mako-d...@googlegroups.com


it would be nice to get #135 in. I'd like someone to illustrate how to reproduce that error.

cd34

unread,
May 29, 2010, 11:49:00 PM5/29/10
to Mako Templates for Python
Ironic that I deleted the tosca.tar.bz2 file yesterday which included
a complete test project with the pylonshf.diff file.

http://cd34.com/tosca.tar.bz2 contains a complete project including
the modified pylonshf.py which needs to be moved into place.

You need to follow the top chunk of this:

http://groups.google.com/group/toscawidgets-discuss/msg/f40676043e4134e0

and you need

http://groups.google.com/group/toscawidgets-discuss/attach/aca58bf394675abf/pylonshf.diff
(or copy the pylonshf.py file to the proper location. ToscaWidgets
has not done a release with that modification)

The error with ToscaWidgets is present in 0.10rc1/1.0rc1 (and
consequently 0.10/1.0)

Feel free to contact me directly if you want.

Michael Bayer

unread,
May 30, 2010, 12:35:53 PM5/30/10
to mako-d...@googlegroups.com

correct if me if I'm wrong, that's the issue for 132, which is fixed. I'm looking for a test for #135. I think its as simple as calling the traceback handler with None for the stack trace.

Just trying to save myself 10 minutes of effort....


cd34

unread,
May 30, 2010, 4:30:09 PM5/30/10
to Mako Templates for Python
You are correct. Marcin Kasperski's error was related to #132. You
referenced #135 and my brain didn't notice the difference. #132
hasn't been pushed to a release, right? I'm still using the tip that I
pulled. I need to pay a little more attention it seems.
Reply all
Reply to author
Forward
0 new messages