This is an automated email from the ASF dual-hosted git repository.

brondsem pushed a commit to branch db/8528
in repository https://gitbox.apache.org/repos/asf/allura.git

commit e0ce8c2ba87cb81ae389c34d959a3c09be33ce51
Author: Dave Brondsema <[email protected]>
AuthorDate: Tue Nov 21 09:51:16 2023 -0500

    [#8528] pass allura_command to allura.command_init entry point functions; 
document it
---
 Allura/allura/command/base.py         | 3 +++
 Allura/docs/development/extending.rst | 5 +++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/Allura/allura/command/base.py b/Allura/allura/command/base.py
index efa3add20..65b7c758e 100644
--- a/Allura/allura/command/base.py
+++ b/Allura/allura/command/base.py
@@ -112,7 +112,10 @@ class Command(command.Command, 
metaclass=MetaParserDocstring):
             # Probably being called from another script (websetup, perhaps?)
             log = logging.getLogger('allura.command')
             conf = tg.config
+
         self.tools = list(tg.app_globals.entry_points['tool'].values())
+
+        conf['allura_command'] = self
         for ep in h.iter_entry_points('allura.command_init'):
             log.info('Running command_init for %s', ep.name)
             ep.load()(conf)
diff --git a/Allura/docs/development/extending.rst 
b/Allura/docs/development/extending.rst
index 9129b462e..7a9484927 100644
--- a/Allura/docs/development/extending.rst
+++ b/Allura/docs/development/extending.rst
@@ -41,13 +41,14 @@ The available extension points for Allura are:
 * :class:`allura.lib.phone.PhoneService`
 * ``site_stats`` in the root API data.  Docs in 
:class:`allura.controllers.rest.RestController`
 * :mod:`allura.lib.package_path_loader` (for overriding templates)
-* ``[allura.timers]`` functions which return a list or single 
:class:`timermiddleware.Timer` which will be included in stats.log timings
+* ``[allura.timers]`` entry-point functions which return a list or single 
:class:`timermiddleware.Timer` which will be included in stats.log timings
 * :mod:`allura.ext.user_profile.user_main`
 * :mod:`allura.ext.personal_dashboard.dashboard_main`
-* ``[allura.middleware]`` classes, which are standard WSGI middleware.  They 
will receive the ``app`` instance and a ``config`` dict as constructor 
parameters.
+* ``[allura.middleware]`` entry-point classes, which are standard WSGI 
middleware.  They will receive the ``app`` instance and a ``config`` dict as 
constructor parameters.
   The middleware will be used for all requests.  By default the middleware 
wraps the base app directly and other middleware wrap around it.
   If your middleware needs to wrap around the other Allura middleware (except 
error handling), set ``when = 'outer'`` on your middleware.
 * :class:`allura.webhooks.WebhookSender`
+* ``[allura.command_init]`` entry-point functions which will be run before all 
commands like ``ensure_index``, ``taskd`` etc.  Receives a ``config`` dict with 
full config plus a ``allura_command`` key which references the current 
command's class.
 
 A listing of available 3rd-party extensions is at 
https://forge-allura.apache.org/p/allura/wiki/Extensions/
 

Reply via email to