Skip to content

Commit 8d0d8e9

Browse files
authored
Merge pull request dmm-com#1644 from syucream/fix/describe-plugin-hooks
docs: clarify interaction between hooks and overrides in plugin system
2 parents 63132cf + 09656ee commit 8d0d8e9

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

airone/lib/plugin_dispatch.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ class PluginOverrideMixin:
2929
If found, the request is dispatched to the plugin handler instead
3030
of the default ViewSet implementation.
3131
32+
When an override is active, the normal ViewSet processing — including
33+
Job creation and hook invocation — is skipped entirely. The override
34+
handler is responsible for the full operation. If the handler needs
35+
hooks (@entry_hook) to fire, it must create a Job internally.
36+
3237
Usage:
3338
class EntryAPI(PluginOverrideMixin, viewsets.ModelViewSet):
3439
...

plugin/examples/pagoda-cross-entity-plugin/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,17 @@ Entity binding is now done via configuration:
333333
export BACKEND_PLUGIN_ENTITY_OVERRIDES='{"42": {"plugin": "cross-entity-sample", "operations": ["retrieve"], "params": {}}}'
334334
```
335335

336+
## Interaction Between Hooks and Overrides
337+
338+
When an override handler is active for an entity/operation, the normal ViewSet processing flow (including Job creation) is bypassed. This has implications for `@entry_hook` hooks:
339+
340+
- **Override uses Job internally**: If your override handler creates a Job (e.g., `job_register_entry`) to perform the actual operation, hooks registered via `@entry_hook` **will fire** as normal, because the Job triggers the same code path that fires hooks.
341+
- **Override does NOT use Job**: If your override handler performs the operation directly (e.g., calling `Entry.objects.create()` or manipulating models without a Job), hooks **will NOT fire**, because the hook invocation is tied to the Job execution path.
342+
343+
This is by design — an override replaces the entire operation, so the plugin author decides whether to go through the standard Job pipeline or not.
344+
345+
The sample `handlers.py` in this plugin uses the Job-based pattern, so hooks will fire for overridden operations.
346+
336347
## Development Notes
337348

338349
- Handlers are registered during plugin initialization via the override registry

plugin/sdk/pagoda_plugin_sdk/override.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ def handle_create(self, context: OverrideContext):
8383
- entry: Entry instance (for retrieve/update/delete)
8484
- data: Request data dict (for create/update)
8585
- params: Plugin-specific parameters from configuration
86+
87+
Note:
88+
Override handlers bypass the normal ViewSet -> Job flow. If your handler
89+
creates a Job internally (e.g., job_register_entry), hooks registered via
90+
@entry_hook will still fire. If your handler performs the operation directly
91+
without a Job, hooks will not execute.
8692
"""
8793
if operation.lower() not in _VALID_OPERATIONS:
8894
raise ValueError(

0 commit comments

Comments
 (0)