I'm in the process of writing taglibs around some existing objects. Before I got to deep into that process, I became curious as to how to best keep state between method calls in an XSP taglib [under mod_perl].

Let's assume we have this simple XSP structure:

        <myobj:load filter1="foo">
                <filter>
                        <filter2>bar</filter2>
                </filter>

                <myobj:name/>
                <myobj:description/>

                <myobj:list>
                        <myobj:list-name/>
                </myobj:list>
        </myobj:load>

In TaglibHelper, this is simply:

        load(;$filter1,$filter2,*filter)
        name()
        description()
        list()
        list-name()


Now, it's easy to load what needs loaded in load(), and then later name/description/list all use the loaded object. My question is, where's the best place to store that object?


I would think locally is bad due to possible concurrency/lifetime issues with the taglib:

        package MYTagLib;

        my $obj;

        sub load( $obj = magickloader($filter1) )
        sub name( return $obj->name )
        ...

Of course, there's pnotes:

        sub load( $r->pnotes(MYOBJ => $obj )
        sub name( $r->pnotes(MYOBJ)->name )
        ...

Maybe I'm just over complicating this. It also seems that there are two distinct approaches to taglibs: helpers that spit out data from your methods, and taglibs that spit out actual code.

Maybe I'm barking up the wrong tree by using a helper, when it would be better to to it the long way and have it write out the needed code to the DOM instead?

Thanks,
-=Chris

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to