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
...
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...
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
{"a": 1, "b": 2}
so mako changes the " to " som...
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...
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
...
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.
...
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...