By putting an empty __init__.py file inside of templates I have eliminated
the ImportError. Can anyone explain why this is necessary? Any pointers to
where I should have learned about this? Nothing I found mentioned needed
this for a simple web.py example.
Next up though I get the following error:
<type 'exceptions.AttributeError'> at /'module' object has no attribute
'index'
So it is not exactly fixed. There is an index.html file in templates yet
the render.index call seems to fail.
Any ideas?
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/-/f91XdwTelysJ.
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.