Workspace holds database connection, metadata, data store configuration and other information or data that can be shared between borwsers.
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).
Creates a workspace from configuration config which should be a ConfigParser object.
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:
Finds the backend with name backend_name. First try to find backend relative to the cubes.backends.* then search full path.
Initializes the base class for cubes workspace. Prepares all model’s translations. Provides attributes:
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)
Tries to translate the model. Looks for language in configuration file under [translations], if no translation is provided, then model remains untouched.