pyramid_handlers
API¶
-
pyramid_handlers.
add_handler
(self, route_name, pattern, handler, action=None, **kw)¶ Add a Pylons-style view handler. This function adds a route and some number of views based on a handler object (usually a class).
This function should never be called directly; instead the
pyramid_handlers.includeme
function should be used to include this function into an application; the function will thereafter be available as a method of the resulting configurator.route_name
is the name of the route (to be used later in URL generation).pattern
is the matching pattern, e.g.'/blog/{action}'
.handler
is a dotted name of (or direct reference to) a Python handler class, e.g.'my.package.handlers.MyHandler'
.If
{action}
or:action
is in the pattern, the exposed methods of the handler will be used as views.If
action
is passed, it will be considered the method name of the handler to use as a view.Passing both
action
and having an{action}
in the route pattern is disallowed.Any extra keyword arguments are passed along to
add_route
.See views_chapter for more explanatory documentation.
-
class
pyramid_handlers.
action
(**kw)¶ Decorate a method for registration by
add_handler()
.Keyword arguments are identical to
view_config
, with the exception to how thename
argument is used.name
- Designate an alternate action name, rather than the default behavior of registering a view with the action name being set to the methods name.