mako

Best Practices for Python UnicodeDecodeError

I use Pylons framework, Mako template for a web based application. I wasn't really bother too deep into the way python handles the unicode strings. I had tense moment when I did see my site crash when the page is rendered and later I came to know that it was related to Unicode Decode error http://wiki.python.org/moin/UnicodeDecodeError ...

Mako templates with Google App Engine

I want to use Mako templates with GAE instead of Django templates. I found this post http://blog.pansapiens.com/2008/06/24/mako-templates-in-google-app-engine-seems-to-work-for-me/ I downloaded Mako from this page by using easy_install http://www.makotemplates.org/download.html But that gave me a "beaker" file c:\python26\lib\site-pa...

Encoding JSON in Mako?

Im having trouble with json in mako. I do this: ${ to_json( dict( a = 1, b = 2 ) ) } where to_json is: <%! import simplejson as json def to_json( d ): return json.dumps( d ) %> however, instead of giving me {"a": "1", "b": "2"} its giving me {&quot;a&quot;: 1, &quot;b&quot;: 2} so mako changes the " to " som...

Search form in Google App Engine with Mako Template

The script is in data.py and template file is search.mako. The search form is in MainPage method (not included in the code below). I enter the search term but nothing happens. Can you help understand what I am doing wrong? Thank you. class Pet(db.Model): name = db.StringProperty() class Search(webapp.RequestHandler): def post(s...

In mako template: call python function within html string

How do I do this in mako: <%! import cherrypy %> ... <link rel="stylesheet" href="${cherrypy.url('/media/layout.css')}" type="text/css" /> AttributeError: 'Undefined' object has no attribute 'url' edit Solved ...

Conditional table with Mako

I was trying to format lists into tables by using Python nested lists. This is my previous question. So far I could not make it work. I was wondering if Mako templates would be better. Can anyone suggest a solution? Thanks. ...

Printing lists with Mako template (Django Join tag)

In this article Django templates like this {% for i in mylist %} <tr> <td>{{i.replist|join:"</td><td>" }}</td> </tr> {% endfor %} prints the list mylist which is an object. Can this be done in Mako? Thanks. EDIT class Rep(db.Model): author = db.UserProperty() replist = db.ListProperty(str) unique = db.ListPropert...