On Fri, Apr 8, 2011 at 4:36 PM, Gregory Crosswhite
<[email protected]> wrote:

> I was wondering why you brought up monkey patching, but having thought about
> it I see that although you didn't say this explicitly, I see now that
> subclassing wouldn't work since most of the time the moment when the
> instance is created is not when I call the constructor but rather when I
> call one of the loading methods, which means that I don't get to control
> exactly what class is instantiated.  Therefore, I need to patch the instance
> myself, essentially implementing myself the same kind of daisy-chained
> namespace lookup procedure that Python normally would implement
> automatically through subclassing.

In practice, you just monkey-patch Leo's core in the plugin's init
function, at the top level of your plugin.  One global patch suffices
to patch all future instances of the patched class.  It's slick.

EKR

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en.

Reply via email to