This pull-requests introduces new extensions interface. The old pkg_resource based discovery was removed as it is not standard. We are now using the __init_subclass__() method to register the subclasses.
Added new class Extensible and all top-level abstract classes for extensions should inherit from this class. The top-level abstract classes have to provide their own __extension_type__ class variable.
Extensions are created by subclassing one of the abstract class and explicitly providing extension name:
class MyStore(Store, name="my"):
...
The extensions are retrieved through:
store: Store
store = Store.concrete_extension("my")(...)
# Or initialize from configuration:
store = Store.concrete_extension("my").create_with_params(config)
To manually register extension:
from cubes.ext import get_registry()
registry = get_registry("store")
registry.register_extension("my", MyStore)
To register extension that lives in a module that is guaranteed to be loadable by standard Python means, but we don't want it to be loaded if not needed:
This pull-requests introduces new extensions interface. The old
pkg_resource
based discovery was removed as it is not standard. We are now using the__init_subclass__()
method to register the subclasses.Added new class
Extensible
and all top-level abstract classes for extensions should inherit from this class. The top-level abstract classes have to provide their own__extension_type__
class variable.Extensions are created by subclassing one of the abstract class and explicitly providing extension name:
The extensions are retrieved through:
To manually register extension:
To register extension that lives in a module that is guaranteed to be loadable by standard Python means, but we don't want it to be loaded if not needed:
Note that we don't need to specify class as it will be automatically registered by loading that module when needed.
Other changes:
ext-info
command was renamed toextension
and an option--try-import
to test load-ability of the extensions was added.