Lazily registering hooks?

Jelmer Vernooij jelmer at samba.org
Sun May 30 19:59:23 BST 2010


On Sun, 2010-05-30 at 20:24 +0200, Gary van der Merwe wrote:
> On Sun, May 30, 2010 at 7:01 PM, Jelmer Vernooij <jelmer at samba.org> wrote:
> > On Sun, 2010-05-30 at 11:56 -0500, John Arbash Meinel wrote:
> >> The best I can think of still just ends up with a central registry. The
> >> Hook code could be localized, but it would end up saying "what bits were
> >> interested in my hook", and then call back to have them loaded.
> > That doesn't seem too bad actually, especially given this could all be done
> > under the covers in bzrlib.hooks (and the plugins would have to be updated, of
> > course).
> 
> We could have deprecated properties where the old hook was, pointing
> to the new centralized hook. Then old plugins will just give a
> deprecated warning, rather than fail with a AttributeError.
I think what John proposed was to have a dictionary with lazily loaded
hooks in bzrlib.hooks. When a particular hookpoint itself gets loaded it
uses that dictionary to find all its hooks that were lazily loaded. This
way the hooks can still exist in e.g. bzrlib.branch and you don't have
to patch bzrlib.hooks every time you add a new hook. 

John, please correct me if this is different from what you had in mind. 

Cheers,

Jelmer



More information about the bazaar mailing list