0.3.4 google app engine compatible?

12 views
Skip to first unread message

chris.vickerson

unread,
Jul 19, 2010, 2:11:00 PM7/19/10
to Mako Templates for Python
Hi,

I just tried to use mako in the app engine development environment and
I'm getting an error with importing the "markupsafe" module. I think
this is not a pure python module so it's not accessible to this
environment. Is this correct and is there a work around for this?

Kind regards,

Chris Vickerson

Michael Bayer

unread,
Jul 19, 2010, 3:43:42 PM7/19/10
to mako-d...@googlegroups.com
we'd have to throw some kind of try/except around the import of Markupsafe and fallback to a substitute. A patch is below but I'm not sure what to do inside of setup.py for this (maybe detect GAE and change the setup() call).

diff -r 286dd28eadbc mako/filters.py
--- a/mako/filters.py Tue Jul 13 11:11:00 2010 -0400
+++ b/mako/filters.py Mon Jul 19 15:43:13 2010 -0400
@@ -8,7 +8,6 @@
import re, urllib, htmlentitydefs, codecs
from StringIO import StringIO
from mako import util
-import markupsafe

xml_escapes = {
'&' : '&',
@@ -21,13 +20,17 @@
# XXX: " is valid in HTML and XML
# ' is not valid HTML, but is valid XML

-def html_escape(string):
- return markupsafe.escape(string)
-
def legacy_html_escape(string):
"""legacy HTML escape for non-unicode mode."""

return re.sub(r'([&<"\'>])', lambda m: xml_escapes[m.group()], string)
+
+try:
+ import markupsafe
+ def html_escape(string):
+ return markupsafe.escape(string)
+except:
+ html_escape = legacy_html_escape

def xml_escape(string):
return re.sub(r'([&<"\'>])', lambda m: xml_escapes[m.group()], string)

> --
> 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.
>

chris.vickerson

unread,
Jul 19, 2010, 4:06:21 PM7/19/10
to Mako Templates for Python
Thank you Michael,

Can you tell me if Google App Engine is a priority for the Mako
Templates developers? Mako is by far my favorite template library but
I want to be realistic too.

Kind regards,

Chris Vickerson

Michael Bayer

unread,
Jul 19, 2010, 4:10:36 PM7/19/10
to mako-d...@googlegroups.com
the GAE implementation I think was a Philip Jenvey thing. Maybe he can chime in on this.
Reply all
Reply to author
Forward
0 new messages