vispa.tools package¶
Submodules¶
vispa.tools.ajax module¶
Definition of the vispa ajax tool.
-
class
vispa.tools.ajax.AjaxTool¶ Bases:
cherrypy._cptools.ToolAjax tool that takes the output of a wrapper inner function and returns a json encoded dictionary containing the following entries: - code: A response code, basically an appropriate http status. The status of the
cherrypy response object is also set to this value. Thus, the code is 200 if there were no errors.- data: The attached payload with an arbitrary type.
- message: In case of an error, i.e. code != 200, an additional error message. On success, i.e. code = 200, this should be empty.
- alert: A boolean that desribes whether the error message should be shown in the GUI using a dialog or something similar.
-
callable(encoded=False)¶ The callable of this tool. If encoded is True, the return value of the wrapped inner function is expected to be already json encoded. Otherwise, it will be encoded using
json.dumps().
vispa.tools.db module¶
-
class
vispa.tools.db.SqlAlchemyTool(engine)¶ Bases:
cherrypy._cptools.Tool-
bind_session()¶ Attaches a session to the request’s scope by requesting the SA plugin to bind a session to the SA engine.
-
commit_transaction()¶ Commits the current transaction or rolls back if an error occurs. Removes the session handle from the request’s scope.
-
vispa.tools.device module¶
vispa.tools.json_parameters module¶
vispa.tools.method module¶
Definition of the vispa method tool.
-
class
vispa.tools.method.MethodTool¶ Bases:
cherrypy._cptools.ToolBasically, the method tool implements the same functionality as cherrypy’s built-in “allow” tool, but in addition, this tool is compliant to our ajax tool.
-
callable(accept=None, reject=None, ajax=True)¶ Actual tool logic. Checks whether a request is sent with a valid HTTP method using accept and reject. Both of them can be strings or iterables of strings. When the request not accepted and ajax is True, the ajax tool is used to send an error. Otherwise, a cherrypy.HTTPError is raised.
-
vispa.tools.parameters module¶
Cherrypy tool that moves parameters that start with an underscore from the querystring to request.private_params.
vispa.tools.permission module¶
-
class
vispa.tools.permission.PermissionTool¶ Bases:
cherrypy._cptools.Tooluse from config file:
[/path/to/protected/resource] tools.permission.on = True tools.permission.requiredPermissions = [‘myextension.read’, ‘myextension.write’]
use as decorator: @cherrypy.expose @cherrypy.tools.permission(requiredPermissions=[‘myextension.resources’]) def resource(self):
return “Hello, %s!” % cherrypy.request.loginParameters: - requiredPermissions – string or iterable of strings, which the user must all have in the global project. If the user management is not automatically setup, the tool does nothing
- ignoreInexistentPermissions – when true, requiredPermissions are ignored if they do not exist
vispa.tools.status module¶
vispa.tools.template module¶
vispa.tools.user module¶
Definition of the vispa user tool.
-
class
vispa.tools.user.UserTool¶ Bases:
cherrypy._cptools.ToolThe user tool checks whether the session contains the field “user_id”. If it exists, a reference to the corresponding user is stored as “cherrypy.request.user”. Otherwise, the request is either redirected or a 401 error is returned using the ajax tool.