shoop package

Subpackages

Submodules

shoop.configuration module

API for Shoop’s Dynamic Configuration.

Idea of the Dynamic Configuration is to allow storing configuration values similarly as Django settings allows, but in a more flexible way: Dynamic Configuration can be changed with a simple API and there is no need restart the application server after changing a value.

Dynamic configuration values are permanent. Current implementation stores the values with ConfigurationItem model into database, but that may change in the future.

Configuration values are get and set by a key string. There is a global configuration and a shop specific configuration for each shop. Values in shop specific configuration override the values in global configuration.

shoop.configuration.set(shop, key, value)[source]

Set configuration item value for a shop or globally.

If given shop is None, the value of given key is set globally for all shops. Otherwise sets a shop specific value which overrides the global value in configuration of the specified shop.

Parameters:
  • shop (shoop.core.models.Shop|None) – Shop to set value for, or None to set a global value
  • key (str) – Name of the key to set
  • value (Any) – Value to set. Note: Must be JSON serializable.
shoop.configuration.get(shop, key, default=None)[source]

Get configuration value by shop and key.

Global configuration can be accessed with shop=None.

Parameters:
  • shop (shoop.core.models.Shop|None) – Shop to get configuration value for, or None
  • key (str) – Configuration item key
  • default (Any) – Default value returned if no value is set for given key (globally or in given shop).
Returns:

Configuration value or the default value

Return type:

Any

Module contents