slycat.web.server.plugin

class slycat.web.server.plugin.Manager[source]

Bases: object

Manages server plugin modules.

load(plugin_path)[source]

Load plugin modules from a filesystem.

If the the given path is a directory, loads all .py files in the directory (non-recursive). Otherwise, assumes the path is a module and loads it.

register_directory(type, init, user)[source]

Register a new directory type.

Parameters:
  • type (string, required) – A unique identifier for the new directory type.
  • init (callable, required) – Called with parameters specified by an adminstrator in the server config.ini to initialize the directory.
  • user (callable, required) – Called with a username to retrieve information about a user. Must return a dictionary containing user metadata.
register_marking(type, label, badge, page_before=None, page_after=None)[source]

Register a new marking type.

Parameters:
  • type (string, required) – A unique identifier for the new marking type.
  • label (string, required) – Human-readable string used to represent the marking in the user interface.
  • badge (string, required) – HTML representation used to display the marking as a “badge”. The HTML must contain everything needed to properly format the marking, including inline CSS styles.
  • page_before (string, optional) – HTML representation used to display the marking at the top of an HTML page. If left unspecified, the badge representation will be used instead.
  • page_after (string, optional) – HTML representation used to display the marking at the bottom of an HTML page. If left unspecified, the badge representation will be used instead.
  • that the page_before and page_after markup need not be self-contained, i.e. they (Note) –
  • be used together to define a "container" that encloses the page markup. (may) –
register_model(type, finish, ptype=None)[source]

Register a new model type.

Parameters:
  • type (string, required) – A unique identifier for the new model type.
  • finish (callable, required) – Called to finish (perform computation on) a new instance of the model.
  • ptype (string, optional) – A unique page type identifier to be used as the default interface when viewing the model. Defaults to the same string as the model type.
register_model_command(verb, type, command, handler)[source]

Register a custom request handler.

Parameters:
  • verb (string, required) – The HTTP verb for the command, “GET”, “POST”, or “PUT”.
  • type (string, required) – Unique category for the command. Typically, this would be a model, parser, or wizard type.
  • command (string, required) – Unique command name.
  • handler (callable, required) – Called with the database, model, verb, type, command, and optional keyword parameters to handle a matching client request.
register_page(type, html)[source]

Register a new page type.

Parameters:
  • type (string, required) – A unique identifier for the new page type.
  • html (callable, required) – Called to generate an HTML representation of the page.
register_page_bundle(type, content_type, paths)[source]
register_page_resource(type, resource, path)[source]

Register a custom resource associated with a page type.

Parameters:
  • type (string, required) – Unique identifier of an already-registered page type.
  • resource (string, required) – Server endpoint to retrieve the resource.
  • path (string, required) – Absolute filesystem path of the resource to be retrieved. The resource may be a single file, or a directory.
register_parser(type, label, categories, parse)[source]

Register a new parser type.

Parameters:
  • type (string, required) – A unique identifier for the new parser type.
  • label (string, required) – Human readable label describing the parser.
  • categories (list, required) – List of string categories describing the type of data this parser produces, for example “table”.
  • parse (callable, required) – Called with a database, model, input flag, list of file objects, list of artifact names, and optional keyword arguments. Must parse the file and insert its data into the model as artifacts, returning True if successful, otherwise False.
register_password_check(type, check)[source]

Register a new password check function.

Parameters:
  • type (string, required) – A unique identifier for the new check type.
  • check (callable, required) – Called with a realm, username, and password plus optional keyword arguments. Must return a (success, groups) tuple, where success is True if authentication succeeded, and groups is a (possibly empty) list of groups to which the user belongs.
register_plugins()[source]

Called to register plugins after all plugin modules have been loaded.

register_tool(name, hook_point, callable)[source]

Register a new cherrypy tool.

Parameters:
  • name (string, required) – A unique identifier for the new tool.
  • hook_point (string, required) – CherryPy hook point where the tool will be installed.
  • callable (callable object, required) – Called for every client request.
register_wizard(type, label, require)[source]

Register a wizard for creating new entities.

Parameters:
  • type (string, required) – A unique identifier for the wizard.
  • label (string, required) – Human-readable name for the wizard, displayed in the UI.
  • require (dict, required) –

    Requirements in order to use the wizard. Supported requirements include:

    • “action”: “create” - the wizard will be used to create new objects.
    • “action”: “edit” - the wizard will be used to edit existing objects.
    • “action”: “delete” - the wizard will be used to delete existing objects.
    • “context”: “global” - the wizard does not require any resources to run.
    • “context”: “project” - the wizard requires a project to run.
    • “context”: “model” - the wizard requires a model to run.
    • “model-type”:[list of model types] - a model matching one of the given types is required to run the wizard.
register_wizard_resource(type, resource, path)[source]

Register a custom resource associated with a wizard.

Parameters:
  • type (string, required) – Unique identifier of an already-registered wizard.
  • resource (string, required) – Server endpoint to retrieve the resource.
  • path (string, required) – Absolute filesystem path of the resource to be retrieved.