"Lightweight plugins" are now in the DEVELOP branch
With the advent of (the internals of) registerTagHandler in Dakar, plugins became able to register tags via
registerTagHandler. Unfortunately, there is a certain amount of overhead for every enabled plugin, whether or not the plugin is used.
With this in mind, I've implemented the means for developers to create
Tags, which are the functional equivalent of
Plugins that only register Tags. Currently the only requirement is for a Tag to implement a function alled
registerTags which returns a hash of
tag => function
. There are plans underway to make Tags self-documenting which will be described at a later time.
Changes made to implement this:
-
configure now has a section for installed Tags
-
pseudo-install.pl handles installing fooTag
-
create-new-plugin.pl handles creating fooTag
-
TWiki.pm has been rewritten slightly to call registerTags on each enabled Tag. This is done in the BEGIN block, so potentially the code is compiled only once, instead of once for each page. (Someone with more knowledge of how cgi=s and =mod-perl should feel free to fill in more details about this. Please!)
People should note that all of the current TWikiVariables can be implemented this way. This will
probably not result in a speed change in either direction, but would allow both easier modification of them by developers and the ability to create alternate implementations.
--
Contributors: MeredithLesly
Discussion
One thing to note is that, unlike Plugins, Tags are essentially stateless. That is, each tag's function gets called when it's seen, but no handlers are called. Since a TWiki instance is passed in as the first argument, the current context can be checked but that's about it. A tag handler can, of course, store information either in the session or in its workarea, but that's about it.
Currently tags don't kill TWiki the way they did in the first release, but they're also not logging errors for debugging purposes. Someone wanna help me with that?
--
MeredithLesly - 07 Apr 2006
This is a great idea. Well done for getting it in.
If I get a development opportunity I will help.
M.
--
MartinCleaver - 08 Apr 2006