rPath Appliance Platform Agent:Plugin Decorators
From rPath Wiki
|
The rPath Appliance Platform Agent provides decorators for the Python plugin code to modify the behavior of the plugin. The agent provides two decorators in its framework: raa.web.expose (required) and raa.web.require (optional). If it is used, raa.web.require should be on the line after raa.web.expose.
raa.web.expose
The raa.web.expose decorator tells the rPath Appliance Platform how to expose the method: with a template, with XML-RPC, or with JSON. Use arguments together as needed:
| @raa.web.expose(template="<project.plugin.display>") | The output of this method will be passed to a kid template, and the result of the template is sent to the user |
| @raa.web.expose(template="<project.plugin.display>", allow_xmlrpc=True) | Expose a method for the web interface and for XML-RPC ** |
| @raa.web.expose(allow_json=True) | The output of this method will be sent as JSON, used by JavaScript to communicate with the server |
| @raa.web.expose(allow_xmlrpc=True) | Expose the method as XML-RPC ** |
| @raa.web.expose(allow_xmlrpc=True, allow_json=True) | Expose a method for both XML-RPC and JSON ** |
| NOTE: The rPath Appliance Platform does not allow you to expose the same method with a template and json. | |
| ** See the rAPA XML-RPC page for further information about how existing rAPA code is using XML-RPC. | |
raa.web.require
The raa.web.require decorator provides control access to a method. This could be used to allow logged-in user, anonymous, or localhost-only access to the method. This optional decorator is used in conjunction with a raa.web.expose. In the absence of raa.web.require, the default is to be logged in as a user in the role of admin (@raa.web.require(raa.authorization.AnyPermissionPresent('admin'))).
| @raa.web.require(raa.authorization.AnyPermissionPresent('<role>')) | Users without the role <role> will be denied access |
| @raa.web.require(raa.authorization.NotAnonymous()) | Users who are not logged in are redirected to the login page |
| @raa.web.require(raa.authorization.LocalhostOnly()) | Only connections originating from the system itself (localhost) are accepted |
| @raa.web.require(None) | Bypass authorization requirements |
