rebecca.view
is helper classes for pyramid views.
properties
context
view context passed to constructorrequest
request passed to constructorresponse
response attribute ofrequest
body
body attribute ofrequest
methods
redirect(url)
create HTTPFound object from urlredirect_route(route_name, **values)
create HTTPFound object with route_urlaction_dispatch
call method named*_action
with request param.
Softification
is context manager to replace Exceptions to the other Exceptions.
with Softification(NoResultFound, HTTPNotFound): item = DBSession.query(Item).filter(Item.id==id).one()
If one()
method raises NoResultFound
exception, the context manager catch that
and raises the HTTPNotFound exception.
You can use tuple for target Exception classes.
To use BasicView
, inherit that simply.:
class Greeting(BasicView): def __call__(self): return self.redirect_route('top', v=1)