Learning pyramid (python) and am struggling with the @view_config decorator. Should it just work out of the box? -
i still learning pyramid, , @ point trying learn how use decorators. below copy of test view callable.
from pyramid.response import response pyramid.view import view_config pyramid.renderers import render_to_response def my_blog(request): return {'project':'tricky'} @view_config( renderer='templates/foo.pt' ) def foo_blog(request): return {'name':'tricky'}
from can understand view_config decorator, can used set application configurations without setting them in config file. in case of example, setting renderer templates/foo.pt. not ever work.
however, if set renderer in config file (init.py) such:
config.add_route( 'foo_blog' , '/blog/{foo}' , view='tricky.views.blog.blog.foo_blog' renderer='tricky:templates/mytemplate.pt' )
it work.
am doing wrong preventing me being able use decorator. thanks!
in order configurations added via @view_config work, need call config.scan() @ point.
Comments
Post a Comment