Skip to content

Instantly share code, notes, and snippets.

@radiosilence
Created April 15, 2010 14:12
Show Gist options
  • Save radiosilence/367128 to your computer and use it in GitHub Desktop.
Save radiosilence/367128 to your computer and use it in GitHub Desktop.
def render_template(template, **context):
mylookup = TemplateLookup(directories=[TEMPLATE_PATH])
mytemplate = mylookup.get_template( template )
return Response( mytemplate.render_unicode( **context ) )
james@potato-linux ~/dev/wz-tut-1 $ python run.py
Traceback (most recent call last):
File "/usr/local/lib/python2.6/dist-packages/gevent/wsgi.py", line 120, in handle
result = server.application(env, self.start_response)
File "/home/james/dev/wz-tut-1/shorty/application.py", line 36, in __call__
return self.dispatch(environ, start_response)
File "/usr/local/lib/python2.6/dist-packages/werkzeug/wsgi.py", line 406, in __call__
return self.app(environ, start_response)
File "/home/james/dev/wz-tut-1/shorty/application.py", line 29, in dispatch
response = handler(request, **values)
File "/home/james/dev/wz-tut-1/shorty/views.py", line 33, in cocks
return render_template('asd.html', id=id)
File "/home/james/dev/wz-tut-1/shorty/utils.py", line 51, in render_template
return Response( mytemplate.render_unicode( **context ) )
NameError: global name 'mytemplate' is not defined
Failed to handle request:
request = <http_request "GET /asd/12313123 HTTP/1.1" 127.0.0.1:57684>
application = <shorty.application.Shorty object at 0x88e89ac>
127.0.0.1 - - [2010-04-15 15:11:04] "GET /favicon.ico HTTP/1.1" 404 238 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/533.2 (KHTML, like Gecko) Chrome/5.0.342.9 Safari/533.2"
def render_template(template, **context):
mylookup = TemplateLookup(directories=[TEMPLATE_PATH])
mylookup.template_args = { "input_encoding": "utf-8" }
mytemplate = mylookup.get_template( template )
return Response( mytemplate.render_unicode( **context ) )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment