Node views¶
-
class
nodular.view.
NodeView
(node, user=None, permissions=None)¶ Base class for node view handlers, to be initialized once per view render. Views are typically constructed like this:
class MyNodeView(NodeView): @NodeView.route('/') def index(self): return u'index view' @NodeView.route('/edit', methods=['GET', 'POST']) @NodeView.route('/', methods=['PUT']) @NodeView.requires_permission('edit', 'siteadmin') def edit(self): return u'edit view' @NodeView.route('/delete', methods=['GET', 'POST']) @NodeView.route('/', methods=['DELETE']) @NodeView.requires_permission('delete', 'siteadmin') def delete(self): return u'delete view'
Parameters: - node (
Node
) – Node that we are rendering a view for. - user – User that the view is being rendered for.
-
static
requires_permission
(permission, *other)¶ Decorator to enforce a permission requirement on a view.
Parameters: - permission (string) – Permission required to access this handler.
- other – Other permissions, any of which can be used to access this handler.
Available permissions are posted to
flask.g.permissions
for the lifetime of the request.
-
static
route
(rule, endpoint=None, methods=None, defaults=None)¶ Decorator for view handlers.
Parameters: - rule (string) – URL rule. See Werkzeug routing for syntax.
- endpoint (string) – Endpoint name, defaulting to method name.
- methods (list) – List of HTTP methods (default GET only).
- defaults (dict) – Default values to be passed to handler.
- node (