cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jens Maukisch" <jmauki...@s-und-n.de>
Subject [RT] Pre- and Postfunctions in FlowScript?
Date Fri, 07 Jan 2005 09:49:11 GMT
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. :-) 

WDYT?


Freundliche Grüße / With kind regards
Jens Maukisch
-- 
S&N AG
Competence Center Open Source
Klingenderstr. 5 
D 33100 Paderborn


Mime
View raw message