Lazily registering hooks?
Robert Collins
robertc at robertcollins.net
Sun May 30 20:59:07 BST 2010
A couple of things - we already have a registry of hooks, so there
isn't a big conceptual change there, but I would be sad to see the
details of hooks centralised - if feels bad.
Another thing we could do is supply a hook to trigger that calls back
when some hook point becomes available.
You wouldn't bother with it for most things: effectively all
operations need Tree, Branch, Repository, Lock, Command etc. But to
lazy handle info and rio:
def hook_when_used(modulename, attrname, hooks):
"""Called when a hooks object becomes available.
:param modulename: The module the hooks are defined in. e.g. bzrlib.smart
:param attrname: The attribute within the module. e.g. SmartTCPServer.hooks
:param hooks: The hooks object itself
"""
if (modulename, attrname) == ('bzrlib.msgeditor', 'hooks'):
hooks.install_named_hook(....)
elif ...
And finally, when using this api, you'd get called immediately for
already-present hooks, so you wouldn't need to care about what order
things happen in.
-Rob
More information about the bazaar
mailing list