Workspace Reference

Workspace manages all cubes, their data stores and model providers.

class cubes.Workspace(config=None, stores=None, load_base_model=True, **_options)

Creates a workspace. config should be a ConfigParser or a path to a config file. stores should be a dictionary of store configurations, a ConfigParser or a path to a stores.ini file.


  • stores – dictionary of stores
  • store_infos – dictionary of store configurations
  • namespace – default namespace
  • logger – workspace logegr
  • rot_dir – root directory where all relative paths are looked for
  • models_dir – directory with models (if relative, then relative to the root directory)
  • info – info dictionary from the info file or info section
  • calendar – calendar object providing date and time functions
  • ns_languages – dictionary where keys are namespaces and values are language to translation path mappings.
add_slicer(name, url, **options)

Register a slicer as a model and data provider.

add_translation(locale, trans, ns='default')

Add translation trans for locale. ns is a namespace. If no namespace is specified, then default (global) is used.

browser(cube, locale=None, identity=None)

Returns a browser for cube.


Closes the workspace with all open stores and other associated resources.

cube(ref, identity=None, locale=None)

Returns a cube with full cube namespace reference ref for user identity and translated to locale.

cube_features(cube, identity=None)

Returns browser features for cube

dimension(name, locale=None, namespace=None, provider=None)

Returns a dimension with name. Raises NoSuchDimensionError when no model published the dimension. Raises RequiresTemplate error when model provider requires a template to be able to provide the dimension, but such template is not a public dimension.

The standard lookup when linking a cube is:

  1. look in the cube’s provider
  2. look in the cube’s namespace – all providers within that namespace
  3. look in the default (global) namespace

Flushes the cube lookup cache.


Opens a store name. If the store is already open, returns the existing store.

import_model(model=None, provider=None, store=None, translations=None, namespace=None)

Registers the model in the workspace. model can be a metadata dictionary, filename, path to a model bundle directory or a URL.

If namespace is specified, then the model’s objects are stored in the namespace of that name.

store is an optional name of data store associated with the model. If not specified, then the one from the metadata dictionary will be used.

Model’s provider is registered together with loaded metadata. By default the objects are registered in default global namespace.

Note: No actual cubes or dimensions are created at the time of calling this method. The creation is deferred until cubes.Workspace.cube() or cubes.Workspace.dimension() is called.

Links dimensions to the cube in the context of model with help of provider.


Get a list of metadata for cubes in the workspace. Result is a list of dictionaries with keys: name, label, category, info.

The list is fetched from the model providers on the call of this method.

If the workspace has an authorizer, then it is used to authorize the cubes for identity and only authorized list of cubes is returned.

register_default_store(type_, **config)

Convenience function for registering the default store. For more information see register_store()

register_store(name, type_, include_model=True, **config)

Adds a store configuration.

class cubes.Namespace(name=None)

Creates a cubes namespace – an object that provides model objects from the providers.

add_translation(lang, translation)

Registers and merges translation for language lang


Create a namespace name in the receiver.

cube(name, locale=None, recursive=False)

Return cube named name.

If recursive is True then look for cube in child namespaces.


Returns a tuple (namespace, nsname, basename) where namespace is a namespace conaining cube and basename is a name of the cube within the namespace. For example: if cube is slicer.nested.cube and there is namespace slicer then that namespace is returned and the basename will be nested.cube


Retursn a list of cube info dictionaries with keys: name, label, description, category and info.

namespace(path, create=False)

Returns a tuple (namespace, remainder) where namespace is the deepest namespace in the namespace hierarchy and remainder is the remaining part of the path that has no namespace (is an object name or contains part of external namespace).

If path is empty or not provided then returns self.

If create is True then the deepest namespace is created if it does not exist.


Returns translation in language lang for model object obj within context (cubes, dimensions, attributes, ...). Looks in parent if current namespace does not have the translation.