vispa.tools package

Submodules

vispa.tools.ajax module

Definition of the vispa ajax tool.

class vispa.tools.ajax.AjaxTool

Bases: cherrypy._cptools.Tool

Ajax 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

class vispa.tools.device.DeviceTool

Bases: cherrypy._cptools.Tool

devicematch(agent, device='all')
get_device_name(agent)
groupmatch(agent, group='all')

vispa.tools.json_parameters module

class vispa.tools.json_parameters.JsonParameters

Bases: cherrypy._cptools.Tool

before_handler()

vispa.tools.method module

Definition of the vispa method tool.

class vispa.tools.method.MethodTool

Bases: cherrypy._cptools.Tool

Basically, 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.

class vispa.tools.parameters.PrivateParameterFilter

Bases: cherrypy._cptools.Tool

before_handler()

vispa.tools.permission module

class vispa.tools.permission.PermissionTool

Bases: cherrypy._cptools.Tool

use 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.login
Parameters:
  • 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

class vispa.tools.status.StatusMonitor

Bases: cherrypy._cptools.Tool

Register the status of each thread.

callable()
unregister()

Unregister the current thread.

class vispa.tools.status.ThreadStatus(threadid)

Bases: object

end = None
idle_time()
last_req_time()
start = None
url = None

vispa.tools.template module

class vispa.tools.template.MakoTool(common_data=None)

Bases: cherrypy._cptools.Tool

callable(template=None, common_data=None, **kwargs)

vispa.tools.user module

Definition of the vispa user tool.

class vispa.tools.user.UserTool

Bases: cherrypy._cptools.Tool

The 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.

vispa.tools.workspace module

class vispa.tools.workspace.WorkspaceTool

Bases: cherrypy._cptools.Tool

before_handler(**conf)

Module contents