Workspace Reference

Workspace holds database connection, metadata, data store configuration and other information or data that can be shared between borwsers.

cubes.create_workspace(backend_name, model, **options)

Designated function to create a backend-specific workspace that holds all relevant data and metadata for aggregated browsing.

Use:

>>> workspace = cubes.create_workspace("sql", model, url="postgres://localhost/database")

Most frequently used method of workspace is browser creation:

>>> browser = workspace.browser(cube)

create_workspace finds the backend with name backend_name and creates a workspace instance. The workspace is responsible for database connections and for creation of aggregation browser. You can get a browser with method browser(). The browser returned might be either created or reused, it depends on the backend.

Implementing Backend

The backend should provide a method create_workspace(model, **options) which returns an initialized workspace object.

The workspace object should implement browser(cube).

cubes.create_workspace_from_config(config)

Creates a workspace from configuration config which should be a ConfigParser object.

cubes.create_slicer_context(config)

Create a context for slicer tool commands. This method is meant to be used not only by the slicer server, but can be reaused by any slicer command that requires similar context as the server. For example: validation of model against database, schema creation various helpers...

Returns a dictionary with keys:

  • model - loaded model (with applied translations)
  • translations – model translations
  • locales - list of model locales
  • backend_name - backend name
  • backend - backend module
  • backend_config - backend configuration dictionary
cubes.get_backend(backend_name)

Finds the backend with name backend_name. First try to find backend relative to the cubes.backends.* then search full path.

class cubes.Workspace(model)

Initializes the base class for cubes workspace. Prepares all model’s translations. Provides attributes:

  • model
  • logger
browser(cube, locale=None)

Creates new or provides a shared browser instance. cube is the browsed cube and locale is optional specification of locale to be used for browsing.

Subclasses should implement this method and should ask for a model instance with self.localized_model(locale)

localized_model(locale)

Tries to translate the model. Looks for language in configuration file under [translations], if no translation is provided, then model remains untouched.

Previous topic

Reference

Next topic

Logical Model Reference

This Page