On 28/11/04 10:38 -0800, Brian Ingerson wrote:
> On 28/11/04 09:34 +0000, Andrew McFarland wrote:
> Subclassing is an effective way to extend the formatter. But it really
> doesn't scale well when a lot of different modules want to extend the
> formatter at the same time. That's because you can only have one
> formatter class installed at a time. So you need to decide a linear
> order of subclassing. :(
>
> There is a better way to do it. I'll explain it another time.
Here is something I wrote today:
http://www.kwiki.org/?CodeKwikiSpamWhitelist
It uses a different technique for extending the formatter. The stuff in
the register() method makes sure this class gets loaded in time. Then it
proceeds to modify two existing classes (the hyperlink classes) by
giving them new html() methods. Since I needed to use the same code for
both classes I created an inline mixin class. This is the first time I'd
done something like this, and is a beautiful testament to the power of
Spiffy. I was tickled.
This style of plugin is nice because it can be combined with other
extensions without planning in advance (as long as the others don't also
modify the same classes). Eventually I will publish a more formal
API/methodology for this type of stuff.
FYI, the basic purpose of this plugin is to only render external links,
if they show up in a whitelist. Most of the code in dbm_update is to
sync a flatfile whitelist with a DBM version of the same content. That
way you can just edit a simple file, but the lookups will be fast.
Cheers, Brian