This change introduces a SettingsDict – a dictionary tied to a list of Setting objects which describe the keys and their types. The extension is now defined as:
from cubes.settings import Setting, SettingType
# Store is subclass of Extensible
class MyStore(Store, name="my"):
extension_desc = "My custom store. It limits number of the queries."
extension_settings = [
Setting("url", SettingType.str, desc="Connection URL),
Setting("query_limit", SettingType.int, desc="Max number of rows returned", default=1000),
]
url: str
query_limit: int
def __init__(self, url: str, query_limit: int):
self.url = url
self.query_limit = query_limit
The extension can be initialized in two ways:
create_with_dict(mapping: Mapping[str, Any]) – accepts any kind of mapping, the values are coalesced/cast to the appropriate setting value types. This method is unlikely to be overriden by subclasses.
create_with_settings(settings: SettingsDict) – creates an instance of the extension using already well typed dictionary of setting values. This method might be overriden by subclasses to customize conversion of values that need to be passed to the __init__() method if they differ from advertised settings.
One can see all the details of extensions by running: slicer extension TYPE NAME. To list all extensions: slicer extension TYPE or just slicer extension.
Other changes
This diff also removes the Naming class and dissolves it in the SQL mapper.
This change introduces a
SettingsDict
– a dictionary tied to a list ofSetting
objects which describe the keys and their types. The extension is now defined as:The extension can be initialized in two ways:
create_with_dict(mapping: Mapping[str, Any])
– accepts any kind of mapping, the values are coalesced/cast to the appropriate setting value types. This method is unlikely to be overriden by subclasses.create_with_settings(settings: SettingsDict)
– creates an instance of the extension using already well typed dictionary of setting values. This method might be overriden by subclasses to customize conversion of values that need to be passed to the__init__()
method if they differ from advertised settings.One can see all the details of extensions by running:
slicer extension TYPE NAME
. To list all extensions:slicer extension TYPE
or justslicer extension
.Other changes
Naming
class and dissolves it in the SQL mapper.[naming]
configuration section