TemplateSyntaxError: Caught ImportError while rendering: No module named http (while migrating py2.5 to py2.7 application)

291 views
Skip to first unread message

Mariano Benitez

unread,
Oct 31, 2011, 8:10:53 AM10/31/11
to google-a...@googlegroups.com
I am porting my app to python 2.7 and I got it running until I try to render my templates. I cannot easily trace which tag or filter is causing trouble...

I get the following stack trace:

Caught ImportError while rendering: No module named http
Traceback (most recent call last):
  File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1511, in __call__
    rv = self.handle_exception(request, response, e)
  File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1505, in __call__
    rv = self.router.dispatch(request, response)
  File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1253, in default_dispatcher
    return route.handler_adapter(request, response)
  File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1077, in __call__
    return handler.dispatch()
  File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 547, in dispatch
    return self.handle_exception(e, self.app.debug)
  File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 545, in dispatch
    return method(*args, **kwargs)
  File "/base/data/home/apps/s~regalatufoto-v5/v44.354351615236544078/app/handlers/base.py", line 306, in get
    self.processResponse(self.GetResponse())
  File "/base/data/home/apps/s~regalatufoto-v5/v44.354351615236544078/app/handlers/base.py", line 222, in smartGetResponse
    response = self.buildResponse()
  File "/base/data/home/apps/s~regalatufoto-v5/v44.354351615236544078/app/handlers/base.py", line 344, in buildResponse
    content = renderHtmlTemplate(templatePath, values)
  File "/base/data/home/apps/s~regalatufoto-v5/v44.354351615236544078/app/utils.py", line 115, in renderHtmlTemplate
    return renderTemplate(path, values)
  File "/base/data/home/apps/s~regalatufoto-v5/v44.354351615236544078/app/utils.py", line 95, in renderTemplate
    return template.render(fullpath, values, debug=True)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/ext/webapp/template.py", line 89, in render
    return t.render(Context(template_dict))
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/ext/webapp/template.py", line 169, in wrap_render
    return orig_render(context)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/__init__.py", line 173, in render
    return self._render(context)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/__init__.py", line 167, in _render
    return self.nodelist.render(context)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/__init__.py", line 794, in render
    bits.append(self.render_node(node, context))
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/debug.py", line 72, in render_node
    result = node.render(context)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/loader_tags.py", line 125, in render
    return compiled_parent._render(context)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/__init__.py", line 167, in _render
    return self.nodelist.render(context)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/__init__.py", line 794, in render
    bits.append(self.render_node(node, context))
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/debug.py", line 72, in render_node
    result = node.render(context)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/defaulttags.py", line 361, in render
    from google.appengine._internal.django.core.urlresolvers import reverse, NoReverseMatch
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/core/urlresolvers.py", line 12, in <module>
    from google.appengine._internal.django.http import Http404
TemplateSyntaxError: Caught ImportError while rendering: No module named http

I included django 1.2 and PIL 1.1.7 in the libraries, but no difference...

Any help?
Thanks,
MAriano

Mariano Benitez

unread,
Oct 31, 2011, 8:26:11 AM10/31/11
to google-a...@googlegroups.com
looking at the sources here I found this line: 

from google.appengine._internal.django.http import Http404
package http is not there in the sources, but I found that class Http404 is now in django package itself here


Any help is appreciated!!!

Thanks,

Brian Quinlan

unread,
Oct 31, 2011, 8:38:43 PM10/31/11
to google-a...@googlegroups.com
Hi Mariano,

Thanks for bringing this up. I'll take a look at the issue some time
day and report back.

Cheers,
Brian

> --
> You received this message because you are subscribed to the Google Groups "Google App Engine" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/google-appengine/-/ANIciPS8ikoJ.
> To post to this group, send email to google-a...@googlegroups.com.
> To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.

Brian Quinlan

unread,
Oct 31, 2011, 11:30:49 PM10/31/11
to google-a...@googlegroups.com
Hi Mariano,

You are using the Django "url" tag, which isn't supported by the
google.appengine.ext.webapp,template in the Python 2.7 runtime.

I'll try to make the error message more meaningful.

Cheers,
Brian

Mariano Benitez

unread,
Nov 1, 2011, 3:50:25 AM11/1/11
to google-a...@googlegroups.com
Thanks Brian,

Further question: is there a way to create a similar tag and register it? so I do not need to rewrite all my templates.. :)

Something like this might work?

from google.appengine.ext import webapp
 
register = webapp.template.create_template_register()

def url(blah???):
  pass # but not really, do something here...

register.tag(url)


Does anyone have a snippet to get urls in the new runtime?

Thanks!!

Brian Quinlan

unread,
Nov 1, 2011, 5:26:25 AM11/1/11
to google-a...@googlegroups.com
On Tue, Nov 1, 2011 at 6:50 PM, Mariano Benitez <maria...@gmail.com> wrote:
Thanks Brian,

Further question: is there a way to create a similar tag and register it? so I do not need to rewrite all my templates.. :)

You can look here for the current implementation:

But, depending on the design of your application, I'd consider:
1. changing your templates
2. using django.templates directly

Cheers,
Brian
 

Something like this might work?

from google.appengine.ext import webapp
 
register = webapp.template.create_template_register()

def url(blah???):
  pass # but not really, do something here...

register.tag(url)


Does anyone have a snippet to get urls in the new runtime?

Thanks!!

--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-appengine/-/9oRrOHqPKvcJ.
Reply all
Reply to author
Forward
0 new messages