cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Leszek Gawron <lgaw...@mobilebox.pl>
Subject Re: [RT] Pre- and Postfunctions in FlowScript?
Date Fri, 07 Jan 2005 10:16:54 GMT
Jens Maukisch wrote:
> Hi,
> 
> I recently thought about if it would be useful to
> have pre- and postfunctions in FlowScript which are
> excecuted before and after a normal flow-function.
> 
> The reason was that we needed some components in
> every flow-function and it was not so nice to get
> and release the components in each functions.
> 
> Something like this:
> 
> flow.js:
> 
> var comp1;
> var comp2;
> 
> function preFunc() {
>   comp1 = cocoon.getComponent("comp1");
>   comp2 = cocoon.getComponent("comp2");
> }
> 
> function myFlowFunction1() {
>   comp1.doSomething();
>   comp2.doSomething();
> }
> 
> function myFlowFunction2() {
>   comp1.doIt();
>   comp2.soIt();
> }
> 
> function postFunc() {
>   cocoon.releaseComponent(comp1);
>   cocoon.releaseComponent(comp2);
> }
> 
> sitemap:
> <map:match pattern="*">
>   <map:call function="{1}">
>     <map:parameter name="preFunction" value="preFunc"/>
>     <map:parameter name="postFunction" value="postFunc"/>
>   </map:call>
> </map:match>
> 
> This would call:
> preFunc();
> myFlowFunction();
> postFunc();
> 
> I was wondering if it would be safe to use the 'global' vars
> comp1 and comp2 e.g. if a user has tow parallel requests
> (race conditions?)?
> 
> This is just a basic thought and I'm not sure if it causes
> more problems than it solves. :-) 
> 
There is a cocoon block with intercepted flowscript that was supposed to 
do a functionality similar to what you describe. I am not aware of 
current state of this block though.

-- 
Leszek Gawron                                      lgawron@mobilebox.pl
Project Manager                                    MobileBox sp. z o.o.
+48 (61) 855 06 67                              http://www.mobilebox.pl
mobile: +48 (501) 720 812                       fax: +48 (61) 853 29 65

Mime
View raw message