The __ini__.py file made no sense so I removed it.

Back to Import Error: No module named templates

Now looking into the line 1028 of the templates.py file I notice.

The line ... in my file
render = web.template.render('templates/')

ends up with an error inside a class called GAE_Render

class GAE_Render(Render):
    # Render gets over-written. make a copy here.
    super = Render
    def __init__(self, loc, *a, **kw):
        GAE_Render.super.__init__(self, loc, *a, **kw)
        
        import types
        if isinstance(loc, types.ModuleType):
            self.mod = loc
        else:
            name = loc.rstrip('/').replace('/', '.')
            self.mod = __import__(name, None, None, ['x'])     # line 1028


Why do you think creating an render object is ending up inside of a Google 
App Engine class. 

I'm just running the simple example on the command line.


- Brad






On Monday, November 26, 2012 12:00:51 AM UTC-5, Brad Lucas wrote:
>
> Just starting with the simplest of examples to use templates I get the 
> following error. Has anyone else seen this and can explain what is going on?
>
> python app.py
> Traceback (most recent call last):
>   File "app.py", line 7, in <module>
>     render = web.template.render('templates/')
>   File "/Library/Python/2.6/site-packages/web/template.py", line 1028, in 
> __init__
>     self.mod = __import__(name, None, None, ['x'])
> ImportError: No module named templates
>
>
> My app.py looks like this:
>
> import web
>
> urls = (
>     '/', 'index'
> )
> app = web.application(urls, globals())
> render = web.template.render('templates/')
>
> class index:
>     def GET(self):
>         name = 'Bob'
>         return render.index(name)
>
> if __name__ == "__main__":
>     app.run()
>
>
>
> I have a sub-directory called templates with a file index.html in it.
>
> The index.html file looks like:
>
> $def with (name)
>
> $if name:
>     I just wanted to say <em>hello</em> to $name.
> $else:
>     <em>Hello</em>, world!
>
>
>
>
> Thanks,
>
> Brad
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/webpy/-/P59261dDFgoJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/webpy?hl=en.

Reply via email to