Skip to content

Commit

Permalink
Don't require store to provide model provider; accept empty model in …
Browse files Browse the repository at this point in the history
…import_model()
  • Loading branch information
Stiivi committed Jun 3, 2015
1 parent 0816a20 commit 9cb0797
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions cubes/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,12 @@ def register_store(self, name, type_, include_model=True, **config):

# Get related model provider or override it with configuration
store_factory = ext.store.factory(type_)
provider = store_factory.related_model_provider

if hasattr(store_factory, "related_model_provider"):
provider = store_factory.related_model_provider
else:
provider = None

provider = config.pop("model_provider", provider)

nsname = config.pop("namespace", None)
Expand Down Expand Up @@ -433,7 +438,8 @@ def import_model(self, model=None, provider=None, store=None,
self.logger.debug("Importing model from dictionary. "
"Provider: %s Store: %s NS: %s"
% (provider, store, namespace))

elif model is None:
model = {}
else:
raise ConfigurationError("Unknown model '%s' "
"(should be a filename or a dictionary)"
Expand All @@ -457,7 +463,8 @@ def import_model(self, model=None, provider=None, store=None,
# Link the model with store
store = store or model.get("store")

if store or provider.requires_store():
if store or (hasattr(provider, "requires_store") \
and provider.requires_store()):
provider.bind(self.get_store(store))

# 4. Namespace
Expand Down

0 comments on commit 9cb0797

Please sign in to comment.