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.includemefunction should be used to include this function into an application; the function will thereafter be available as a method of the resulting configurator.route_nameis the name of the route (to be used later in URL generation).patternis the matching pattern, e.g.'/blog/{action}'.handleris a dotted name of (or direct reference to) a Python handler class, e.g.'my.package.handlers.MyHandler'.If
{action}or:actionis in the pattern, the exposed methods of the handler will be used as views.If
actionis passed, it will be considered the method name of the handler to use as a view.Passing both
actionand having an{action}in the route pattern is disallowed.Any extra keyword arguments are passed along to
add_route.See Views 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 thenameargument 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.