Skip to content

Instantly share code, notes, and snippets.

@dmitric
Created October 3, 2012 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmitric/3828280 to your computer and use it in GitHub Desktop.
Save dmitric/3828280 to your computer and use it in GitHub Desktop.
Template
Traceback (most recent call last):
File "/Users/DLC/.virtualenvs/b/lib/python2.7/site-packages/tornado/web.py", line 1021, in _stack_context_handle_exception
raise_exc_info((type, value, traceback))
File "/Users/DLC/.virtualenvs/b/lib/python2.7/site-packages/tornado/stack_context.py", line 258, in _nested
yield vars
File "/Users/DLC/.virtualenvs/b/lib/python2.7/site-packages/tornado/stack_context.py", line 228, in wrapped
callback(*args, **kwargs)
File "/Users/DLC/.virtualenvs/b/lib/python2.7/site-packages/tornado/gen.py", line 382, in inner
self.set_result(key, result)
File "/Users/DLC/.virtualenvs/b/lib/python2.7/site-packages/tornado/gen.py", line 315, in set_result
self.run()
File "/Users/DLC/.virtualenvs/b/lib/python2.7/site-packages/tornado/gen.py", line 345, in run
yielded = self.gen.send(next)
File "/Users/DLC/Code/gkapps/b/handlers/route.py", line 135, in get
is_app=self.is_app)
File "/Users/DLC/.virtualenvs/b/lib/python2.7/site-packages/tornado/web.py", line 500, in render
html = self.render_string(template_name, **kwargs)
File "/Users/DLC/Code/gkapps/handlers/base.py", line 13, in render_string
return tornado.web.RequestHandler.render_string(self, template, **kwargs)
File "/Users/DLC/.virtualenvs/b/lib/python2.7/site-packages/tornado/web.py", line 607, in render_string
return t.generate(**namespace)
File "/Users/DLC/.virtualenvs/b/lib/python2.7/site-packages/tornado/template.py", line 261, in generate
return execute()
File "web/route_html.generated.py", line 429, in _execute
return _utf8('').join(_buffer) # web/base.html:0
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 27: ordinal not in range(128)
#catch link and hashtags or @ mentions
_LINK_RE = re.compile(ur"([@#])([\w]+)")
def link_elements(text):
def make_link(m):
link_type = m.group(1)
if link_type == u'@':
link_type = u'/%s' % m.group(2)
else:
link_type = u'/tag/%s' % m.group(2)
return u'<a href="%s">%s</a>' % (link_type, m.group(0))
return _LINK_RE.sub(make_link, text)
return self.render("t.html", link_elements=link_elements)
{% extends "base.html" %}
{% block body %}
...
{% if len(comments) > 0 and (not is_app or show_comments) %}
<div class="comments">
{% for comment in comments %}
<a class="username" href="/{{ comment["user"]["username"] }}">{{ comment["user"]["username"] }}</a>
<p class="comment">{% apply link_elements %}{{ comment['textContent'] }} {% end %}</p>
{% end %}
</div>
{% end %}
...
{% end %}
{% end %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment