Skip to content

Commit

Permalink
feat: register collections via collection:register_collections signal
Browse files Browse the repository at this point in the history
  • Loading branch information
smotornyuk committed Feb 12, 2024
1 parent 8497e1e commit 6db3be0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ckanext/collection/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ class ApImplementation(p.SingletonPlugin):
pass


register_collection_signal = tk.signals.ckanext.signal(
"collection:register_collections",
)


@tk.blanket.blueprints
@tk.blanket.auth_functions
@tk.blanket.config_declarations
Expand All @@ -62,6 +67,7 @@ class ApImplementation(p.SingletonPlugin):
class CollectionPlugin(ApImplementation, p.SingletonPlugin):
p.implements(p.IConfigurer)
p.implements(p.IConfigurable)
# p.implements(p.ISignal)
p.implements(ICollection, inherit=True)

# IConfigurer
Expand All @@ -79,6 +85,10 @@ def configure(self, config_: CKANConfig):
for name, factory in plugin.get_collection_factories().items():
shared.collection_registry.register(name, factory)

for _, factories in register_collection_signal.send():
for name, factory in factories.items():
shared.collection_registry.register(name, factory)

def get_collection_factories(self) -> dict[str, CollectionFactory]:
if tk.config["debug"]:
from .utils import (
Expand Down

0 comments on commit 6db3be0

Please sign in to comment.