Hi,
I've been playing a little bit with the framework .I was trying to separate
some stuff when I found something weird. Something that I am sure has an
explanation. I did try this:
[main.py]
#!/usr/bin/env python
import web
render = web.template.render('templates/')
web.ctx.render = render
urls = (
'/', 'core.home.home'
)
if __name__ == "__main__":
app = web.application(urls, globals())
app.run()
[core/home.py]
import web
class home:
def GET(self):
i = web.input(name=None)
return web.ctx.render.home(i.name) # here is the "problem"
[templates/home.html]
$def with (name)
$if name:
I just wanted to say <em>hello</em> to $name.
$else:
<em>Hello</em> World!
The problem I am facing is that, when I launch ./main.py and browse to
localhost:8080, the first time it shows up correctly and I can read 'hello
world', but if I reload the page, it always shows me this error:
[ERROR on 2nd RELOAD]
127.0.0.1:39690 - - [18/Nov/2012 18:20:47] "HTTP/1.1 GET /" - 500 Internal
Server Error
Traceback (most recent call last):
File "/code/python/webpy/web/application.py", line 239, in process
return self.handle()
File "/code/python/webpy/web/application.py", line 230, in handle
return self._delegate(fn, self.fvars, args)
File "/code/python/webpy/web/application.py", line 420, in _delegate
return handle_class(cls)
File "/code/python/webpy/web/application.py", line 396, in handle_class
return tocall(*args)
File "/code/python/webpy/core/home.py", line 6, in GET
return web.ctx.render.home(i.name)
AttributeError: 'ThreadedDict' object has no attribute 'render'
It's like if web.ctx was "losing" the 'render'. How is it possible that it
works the first time I browse but not the next ones? I'm using 0.37.
Cheers.
--
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/-/boECF7eo06cJ.
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.