You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Glen Ezkovich <gl...@hard-bop.com> on 2005/01/10 06:09:17 UTC
Blocks, Flow and Dependencies [was RE: Splitting xconf files step 2: the sitemap]
On Jan 9, 2005, at 7:33 PM, Mark Lundquist wrote:
>
>> From: Glen Ezkovich [mailto:glen@hard-bop.com]
>> On Jan 9, 2005, at 4:17 PM, Mark Lundquist wrote:
>>> Do we really want inter-block flowscript function calls?
>
> Actually, I guess we do... there are some blocks that are meant to be
> used
> from flow, for which passing requests and SAX streams isn't the best
> model.
> Think of an authentication module, for instance. Or, to use your
> example,
> Forms!
Of course. But you want to use a service not invoke a javascript
function. What you would want is to get the service, make a request and
get the result. Not knowing what the intricacies of the block system
will be, I would imagine something along the lines of
var authService =
cocoon.get("block://authentication/authenticationService");
var isAuthorized = authService.authorize(user, pwd);
would make more sense. Or more likely this still might be done by the
current service lookup methods but the service will be provided by the
authentication block. (Though I do like the simplicity of the above.)
If you implemented you app's authentication in javascript and deployed
it as a block you could just use it from flow like
cocoon.sendPageAndWait("block://authentication/authenticate",
"block://currentBlock/loginPage");
Where all you are essentially doing is redirecting to the
authentication blocks sitemap. It really just depends on what exactly
it is you want the block to do.
The way I understand it, one of the main points of blocks is to make it
easier to configure Cocoon with just the components you need for your
application. Once the various components are wired together we
shouldn't really need to do anything differently. If a block has a
dependency on another block it should be able to use the existing
methods to realize that dependency. All of the magic should be done by
Cocoon and the Block Manager.
> So, I withdraw my question... but I guess I would like to see what
> block
> contracts would look like at the flow level!
Can you explain what a contract between blocks is? I'm lost here. I
thought a contract was between the client and the
method/function/pipeline it invokes. The client agrees to meet certain
requirements of the method/function/pipeline before invoking it and the
method/function/pipeline then agrees to perform certain tasks and/or
return correct and valid results.
> Perhaps a flowscript object
> that encapsulates the flowscript API for the block?
> Actually, a Java interface could express that...
Seems like overkill.
>
> ~ml
>
>
>
>
Glen Ezkovich
HardBop Consulting
glen at hard-bop.com
http://www.hard-bop.com
A Proverb for Paranoids:
"If they can get you asking the wrong questions, they don't have to
worry about answers."
- Thomas Pynchon Gravity's Rainbow
Re: Blocks, Flow and Dependencies [was RE: Splitting xconf files
step 2: the sitemap]
Posted by Reinhard Poetz <re...@apache.org>.
Reinhard Poetz wrote:
> Daniel Fagerstrom wrote:
>
>> Reinhard Poetz wrote:
>>
>>> Daniel Fagerstrom wrote:
>>
>>
>>
>>
>> <snip/>
>>
>>>> A somewhat unrelated thing that we have to think about is the web
>>>> continuations created in the block, do we need to shield the web
>>>> continuations created in the block or not?
>>>
>>>
>>>
>>>
>>> shielded from what? The user should be able to resume a continuation
>>> created by a called block. (I have the sense that I haven't
>>> understood your last paragraph completly ...)
>>
>>
>>
>> Say that you have a flow script function "a" that goes through a
>> number of forms in your block "A". During the execution of "a" a
>> number of web continuations will be created in your continuation tree.
>> You have a rule for handling this continuations in the sitemap in "A".
>> Now if you use "a" from another block "B", the question is if "B"
>> should be able to access the web continuations that are created in
>> "A". My opinion is that it shoudn't because:
>>
>> 1. There is no need for it as The sitemap rules for handling the use
>> references to these web continuations allready is in "A".
>> 2. It breakes isolation as "B" can call objects (i.e. A's web
>> continuations) that not are part of the exported functionallity.
>>
>> It is AFAIU not particullary hard to implement this isolation. Let the
>> the called block function "a" put its web continuations in an own web
>> continuation sub tree.
>>
>> The user will be able to resume continuations created in "a" but only
>> through sitemap rules that are part of "A", which leads to better
>> isolation.
>>
>> Clearer now?
>
>
> yes, thank you :-)
>
> thank you!
one "thank you" too much. Wanted to write, that I agree with you, that
"shielding" as needed here.
--
Reinhard
Re: Blocks, Flow and Dependencies [was RE: Splitting xconf files
step 2: the sitemap]
Posted by Reinhard Poetz <re...@apache.org>.
Daniel Fagerstrom wrote:
> Reinhard Poetz wrote:
>
>> Daniel Fagerstrom wrote:
>
>
>
> <snip/>
>
>>> A somewhat unrelated thing that we have to think about is the web
>>> continuations created in the block, do we need to shield the web
>>> continuations created in the block or not?
>>
>>
>>
>> shielded from what? The user should be able to resume a continuation
>> created by a called block. (I have the sense that I haven't understood
>> your last paragraph completly ...)
>
>
> Say that you have a flow script function "a" that goes through a number
> of forms in your block "A". During the execution of "a" a number of web
> continuations will be created in your continuation tree. You have a rule
> for handling this continuations in the sitemap in "A". Now if you use
> "a" from another block "B", the question is if "B" should be able to
> access the web continuations that are created in "A". My opinion is that
> it shoudn't because:
>
> 1. There is no need for it as The sitemap rules for handling the use
> references to these web continuations allready is in "A".
> 2. It breakes isolation as "B" can call objects (i.e. A's web
> continuations) that not are part of the exported functionallity.
>
> It is AFAIU not particullary hard to implement this isolation. Let the
> the called block function "a" put its web continuations in an own web
> continuation sub tree.
>
> The user will be able to resume continuations created in "a" but only
> through sitemap rules that are part of "A", which leads to better
> isolation.
>
> Clearer now?
yes, thank you :-)
thank you!
--
Reinhard
Re: Blocks, Flow and Dependencies [was RE: Splitting xconf files
step 2: the sitemap]
Posted by Daniel Fagerstrom <da...@nada.kth.se>.
Reinhard Poetz wrote:
> Daniel Fagerstrom wrote:
<snip/>
>> A somewhat unrelated thing that we have to think about is the web
>> continuations created in the block, do we need to shield the web
>> continuations created in the block or not?
>
>
> shielded from what? The user should be able to resume a continuation
> created by a called block. (I have the sense that I haven't understood
> your last paragraph completly ...)
Say that you have a flow script function "a" that goes through a number
of forms in your block "A". During the execution of "a" a number of web
continuations will be created in your continuation tree. You have a rule
for handling this continuations in the sitemap in "A". Now if you use
"a" from another block "B", the question is if "B" should be able to
access the web continuations that are created in "A". My opinion is that
it shoudn't because:
1. There is no need for it as The sitemap rules for handling the use
references to these web continuations allready is in "A".
2. It breakes isolation as "B" can call objects (i.e. A's web
continuations) that not are part of the exported functionallity.
It is AFAIU not particullary hard to implement this isolation. Let the
the called block function "a" put its web continuations in an own web
continuation sub tree.
The user will be able to resume continuations created in "a" but only
through sitemap rules that are part of "A", which leads to better isolation.
Clearer now?
/Daniel
Re: Blocks, Flow and Dependencies [was RE: Splitting xconf files step 2: the sitemap]
Posted by Glen Ezkovich <gl...@hard-bop.com>.
On Jan 10, 2005, at 10:35 AM, Daniel Fagerstrom wrote:
> Glen Ezkovich wrote:
>
>> I've been thinking about why one would want to isolate a blocks
>> flowscripts from other blocks. So far I see two reasons:
>> 1.) some flowscript functions are simply helper functions and
>> should not be directly callled.
>> 2.) a block may use its own classloader and therefore possibly
>> use different versions of a class then the calling block.
>
>>
>> If you have other reasons please let me know.
>
> 3.) Local pages S,T and U used in a flowscript a defined in a block A
> should be resolved relative A rather than relative B when used in
> block B. See Reinhard's earlier mail:
> http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=110519369529959&w=2
> for an example of this situation, and re-read his and my discussion
> carefully in the light of this ;)
>
> Resolving relative URIs in blocks relative to the caller rather than
> the called block will make it hard or impossible to export complete
> sub flows that do thnigs like creating acounts and what you have.
OK. Don't you think that if we are the calling block we could specify
what our block is and use that as the URI. i.e.
myForiegnFunction("block://caller/path/To/Resource") We could do this
for using resources from any block. I think you can contrive examples
where this may not work, but I think in the end if you examine your
problem space you could find a way to declare and implement things so
that it would in a way that is straightforward.
>
> Another question is of course if we should handle this at the level of
> exporting flowscript functions. In the begining of the discussion I
> sugested that it was enough to handle this by calling the flowscript
> function in the block in a virtual pipeline defined in the block. And
> only export virtual pipline components from blocks (here I assume that
> relative URI resolution is solved for VPCs by using the mechanism
> proposed by Sylvain).
This works for me.
<snip comment="I've said all I have to say returning objects. To me its
simple."/>
>> I don't think its necessary to reinvent the wheel to achieve the
>> results you desire.
>
> This is not about reinventing any wheels it is about:
>
> 1. Provide the possiblity to package reusable sub flows in a block.
> 2. Provide a reasonable semantics to using flowscript functions
> defined in blocks.
I do agree that that is what its about.
> 3. Keep the possiblity for more "secure" isolation open, if we choose
> to provide such things in the future.
This I think is possible without doing anything. Nothing I've suggested
prevents this. Lets just get a basic block based deployer working and
move on from there.
I really think this discussion gets us nowhere until we have see what a
block manager actually does and we have the semantics of a block
protocol in place. Until then I really have nothing more to say and
doubt seriously if what I have said has moved this discussion anywhere.
I still don't see any problem except that flowscript doesn't have
private functions. :-(
Glen Ezkovich
HardBop Consulting
glen at hard-bop.com
http://www.hard-bop.com
A Proverb for Paranoids:
"If they can get you asking the wrong questions, they don't have to
worry about answers."
- Thomas Pynchon Gravity's Rainbow
Re: Blocks, Flow and Dependencies [was RE: Splitting xconf files
step 2: the sitemap]
Posted by Daniel Fagerstrom <da...@nada.kth.se>.
Glen Ezkovich wrote:
> I've been thinking about why one would want to isolate a blocks
> flowscripts from other blocks. So far I see two reasons:
> 1.) some flowscript functions are simply helper functions and
> should not be directly callled.
> 2.) a block may use its own classloader and therefore possibly use
> different versions of a class then the calling block.
>
> If you have other reasons please let me know.
3.) Local pages S,T and U used in a flowscript a defined in a block A
should be resolved relative A rather than relative B when used in block
B. See Reinhard's earlier mail:
http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=110519369529959&w=2 for
an example of this situation, and re-read his and my discussion
carefully in the light of this ;)
Resolving relative URIs in blocks relative to the caller rather than the
called block will make it hard or impossible to export complete sub
flows that do thnigs like creating acounts and what you have.
Another question is of course if we should handle this at the level of
exporting flowscript functions. In the begining of the discussion I
sugested that it was enough to handle this by calling the flowscript
function in the block in a virtual pipeline defined in the block. And
only export virtual pipline components from blocks (here I assume that
relative URI resolution is solved for VPCs by using the mechanism
proposed by Sylvain).
Reinhard pointed out that this will not handle the fact that you often
whant to return a result from a subflow, something that is not handled
by the pipeline api. Either we could solve this by providing an
extension of the pipeline api or by finding an mechanism for exporting
flowscript functions. We followed the second way in the discussion.
Providing the result by letting the flowscript function puting it in a
session variable is rather akward to use, it is a complicated contract
and introduces the possiblity for conflicts between blocks. It is
analoguos with replacing functions with procedures that write their
result in a predetermined global variable in a program language.
> I think the simplest way to handle 1, is to put "private" functions in
> different files and use the blocks configuration file to distinguish
> between public and private flowscript files.
>
> 2 is obviously a more difficult problem. But this is a problem that is
> introduced by the dependancy between two blocks whether flow is
> involved or not. The only way around this is to have the two blocks
> use the same class versions.
>
> The fact that a block provides a service doesn't mean that it does so
> only through its sitemap. The service may be provided in many ways.
> Such as avalon components, sitemap components, VirtualComponents and
> just POJOs. Blocks are much more about modularization, configuration
> and deployment then they are about providing isolated services. Once
> deployed the blocks are part of a web application. If you want to
> isolate each service then I suggest you look at web services in
> general and SOAP in particular. You can look to Jini and RMI as well.
> The problem of independent discoverable services has been solved in
> several ways. I don't think its necessary to reinvent the wheel to
> achieve the results you desire.
This is not about reinventing any wheels it is about:
1. Provide the possiblity to package reusable sub flows in a block.
2. Provide a reasonable semantics to using flowscript functions defined
in blocks.
3. Keep the possiblity for more "secure" isolation open, if we choose to
provide such things in the future.
/Daniel
Re: Blocks, Flow and Dependencies [was RE: Splitting xconf files step 2: the sitemap]
Posted by Glen Ezkovich <gl...@hard-bop.com>.
I've been thinking about why one would want to isolate a blocks
flowscripts from other blocks. So far I see two reasons:
1.) some flowscript functions are simply helper functions and should
not be directly callled.
2.) a block may use its own classloader and therefore possibly use
different versions of a class then the calling block.
If you have other reasons please let me know.
I think the simplest way to handle 1, is to put "private" functions in
different files and use the blocks configuration file to distinguish
between public and private flowscript files.
2 is obviously a more difficult problem. But this is a problem that is
introduced by the dependancy between two blocks whether flow is
involved or not. The only way around this is to have the two blocks use
the same class versions.
The fact that a block provides a service doesn't mean that it does so
only through its sitemap. The service may be provided in many ways.
Such as avalon components, sitemap components, VirtualComponents and
just POJOs. Blocks are much more about modularization, configuration
and deployment then they are about providing isolated services. Once
deployed the blocks are part of a web application. If you want to
isolate each service then I suggest you look at web services in general
and SOAP in particular. You can look to Jini and RMI as well. The
problem of independent discoverable services has been solved in several
ways. I don't think its necessary to reinvent the wheel to achieve the
results you desire.
Glen Ezkovich
HardBop Consulting
glen at hard-bop.com
http://www.hard-bop.com
A Proverb for Paranoids:
"If they can get you asking the wrong questions, they don't have to
worry about answers."
- Thomas Pynchon Gravity's Rainbow
Re: Blocks, Flow and Dependencies [was RE: Splitting xconf files
step 2: the sitemap]
Posted by Reinhard Poetz <re...@apache.org>.
Daniel Fagerstrom wrote:
> Reinhard Poetz wrote:
>
>> Daniel Fagerstrom wrote:
>
>
> <snip/>
>
>>> A question here is what flowscript functions that should be exported
>>> from a block. I would prefer to explictly enumerate the functions and
>>> possibly whole scripts that are exported rather than exporting
>>> everything in the map:flow sections.
>>
>>
>>
>> Maybe we can work with an attribute in the script declaration:
>>
>> <map:script src="public-flowscript.js" public="true"/>
>>
>> (Don't know if this is technically possible because this requires that
>> when we call a function from we must know where it is defined).
>
>
> Or maybe more explicit:
>
> <map:script src="public-flowscript.js" public="fun1 fun2 fun3"/>
ok
>
> Then it is explicit what is exported and it is also easy for the
> framework to find the functions that should be usable from outside.
<snip/>
> Maybe I'm missing something, but a function call always implictly
> creates a continuation. The function call can be seen as: create a
> continuation, save it as a special place in the execution stack, goto
> the first instruction in called function, execute the instructions in
> the function. Then the return means: fetch the saved continuation in the
> execution stack and call it.
>
> The explicitly created continuations, gives you a way to "return" to
> positions in the program execution other than the position after a
> function call.
>
> So I'm not getting why we should need to create the continuation1 and
> resuming it for simulating function call semantics. This is what the
> function call does by it self. Or are there other mechanisms involved
> that I'm missing?
hmmm. sounds reasonable
> A somewhat unrelated thing that we have to think about is the web
> continuations created in the block, do we need to shield the web
> continuations created in the block or not?
shielded from what? The user should be able to resume a continuation created by
a called block. (I have the sense that I haven't understood your last paragraph
completly ...)
--
Reinhard
Re: Blocks, Flow and Dependencies [was RE: Splitting xconf files
step 2: the sitemap]
Posted by Daniel Fagerstrom <da...@nada.kth.se>.
Reinhard Poetz wrote:
> Daniel Fagerstrom wrote:
<snip/>
>> A question here is what flowscript functions that should be exported
>> from a block. I would prefer to explictly enumerate the functions and
>> possibly whole scripts that are exported rather than exporting
>> everything in the map:flow sections.
>
>
> Maybe we can work with an attribute in the script declaration:
>
> <map:script src="public-flowscript.js" public="true"/>
>
> (Don't know if this is technically possible because this requires that
> when we call a function from we must know where it is defined).
Or maybe more explicit:
<map:script src="public-flowscript.js" public="fun1 fun2 fun3"/>
Then it is explicit what is exported and it is also easy for the
framework to find the functions that should be usable from outside.
<snip/>
>> Can you expand on why you fear that it is impossible. Concerning web
>> continuations I would assume that the normal case is that they are
>> local to the block that creates them and handled by rules in the
>> blocks sitemap, and that links are handled with the block link
>> rewriting mechanism. Then it is the block writers choice to put the
>> continuation handling sitemap rule in the external or the internal
>> pipeline.
>>
>> Concering objects that are returned from a block flowscript function
>> I wouldn't don't see any problem (yet ;) ) it is an ordinary Java
>> class, possibly from some Rhino name space.
>
>
> True, but this Java object has to be "put into" the calling script at
> the right place. So you have to freeze the calling script, call the
> flowscript function of the block, this flowscript can produce
> continuations and when this function is finished, the calling
> flowscript has to resume at the right place using the result object of
> the block flowscript.
>
> ... that's the reason why I'm a bit worried
>
>
> Update after reading it again: Maybe we have to create two
> continuations ...
>
> function f_blockA() {
> var x = cocoon.blocks.blockB.createNewAccount(); // create
> continuation 1
> }
>
> ---
>
> function createNewAccount() {
> cocoon.sendPageAndWait("xyz");
> cocoon.sendPageAndWait("abc");
> return new Customer();
> }
>
>
> When createNewAccount() returns the Customer object, "continuation 1"
> is resumed and the return object is assigned to variable x.
>
> ... again, don't have a clue if this works ...
>
Maybe I'm missing something, but a function call always implictly
creates a continuation. The function call can be seen as: create a
continuation, save it as a special place in the execution stack, goto
the first instruction in called function, execute the instructions in
the function. Then the return means: fetch the saved continuation in the
execution stack and call it.
The explicitly created continuations, gives you a way to "return" to
positions in the program execution other than the position after a
function call.
So I'm not getting why we should need to create the continuation1 and
resuming it for simulating function call semantics. This is what the
function call does by it self. Or are there other mechanisms involved
that I'm missing?
A somewhat unrelated thing that we have to think about is the web
continuations created in the block, do we need to shield the web
continuations created in the block or not?
/Daniel
Re: Blocks, Flow and Dependencies [was RE: Splitting xconf files
step 2: the sitemap]
Posted by Reinhard Poetz <re...@apache.org>.
Daniel Fagerstrom wrote:
> Reinhard Poetz wrote:
> <snip/>
>
>> I think of composing an application out of flow calls:
>>
>> function myF() {
>>
>> var newAccount = [here call a flow function of another block]
>> e.g. cocoon.blocks.blockB.createNewAccount();
>> if(newAccount.type == "xyz") {
>> cocoon.sendPage("xyz");
>> }
>> else {
>> cocoon.sendPage("abc");
>> }
>> }
>>
>>
>> So calling another block has to return a Java(script) object (a stream
>> of SAX
>> events doesn't help here!) and I don't want to care which flowscript
>> files have
>> to be loaded to make my call work.
>>
>> If we go this way we have to solve the problem that the flowscript of
>> the other
>> block runs completly isoluated from the calling the block.
>
>
> I think that is the way to go.
>
> The important thing IMO is that when we use a flowscript today, it has
> access to a global context in terms of the cocoon object. When we
> introduce blocks each block must have a own cocoon object. This block
> local cocoon object has access to global stuff as before but also to
> such things that are internal to the block. Also all relative URIs must
> be resolved by relative the block rather than relative the user. There
> might be internal pipelines that the block resolver has access to but
> that not are exported.
>
> This means that we cannot consider the exported flow calls as normal
> java script functions anymore, they are more like methods that are
> invoked at a certain object. And the syntax:
>
> cocoon.blocks.blockB.createNewAccount();
>
> illustrates that interpretation in a nice way.
>
> A question here is what flowscript functions that should be exported
> from a block. I would prefer to explictly enumerate the functions and
> possibly whole scripts that are exported rather than exporting
> everything in the map:flow sections.
Maybe we can work with an attribute in the script declaration:
<map:script src="public-flowscript.js" public="true"/>
(Don't know if this is technically possible because this requires that when we
call a function from we must know where it is defined).
>> This has the
>> advantage that we don't have to work around the missing namespace
>> concept of
>> Javascript but has the disadvantage that we have to find a way that in
>> the other
>> block (runs isolated from the first block) continuations are created
>> and that we
>> have to return the result of this function to the calling block.
>>
>> I fear that this isn't possible ...
>
>
> Can you expand on why you fear that it is impossible. Concerning web
> continuations I would assume that the normal case is that they are local
> to the block that creates them and handled by rules in the blocks
> sitemap, and that links are handled with the block link rewriting
> mechanism. Then it is the block writers choice to put the continuation
> handling sitemap rule in the external or the internal pipeline.
>
> Concering objects that are returned from a block flowscript function I
> wouldn't don't see any problem (yet ;) ) it is an ordinary Java class,
> possibly from some Rhino name space.
True, but this Java object has to be "put into" the calling script at the right
place. So you have to freeze the calling script, call the flowscript function of
the block, this flowscript can produce continuations and when this function is
finished, the calling flowscript has to resume at the right place using the
result object of the block flowscript.
... that's the reason why I'm a bit worried
Update after reading it again: Maybe we have to create two continuations ...
function f_blockA() {
var x = cocoon.blocks.blockB.createNewAccount(); // create continuation 1
}
---
function createNewAccount() {
cocoon.sendPageAndWait("xyz");
cocoon.sendPageAndWait("abc");
return new Customer();
}
When createNewAccount() returns the Customer object, "continuation 1" is resumed
and the return object is assigned to variable x.
... again, don't have a clue if this works ...
--
Reinhard
Re: Blocks, Flow and Dependencies [was RE: Splitting xconf files step 2: the sitemap]
Posted by Glen Ezkovich <gl...@hard-bop.com>.
On Jan 10, 2005, at 9:32 AM, Reinhard Poetz wrote:
> Torsten Curdt wrote:
>>>>> So it seems, flow replaces components? If createNewAccount()
>>>>> gathers sends pages, collects information, creates an Account,
>>>>> etc. then why not just use cocoon.sendPageAndWait?
>>>>
>>>>
>>>>
>>>> because this is done in the called block, not by the callee.
>>>
>>>
>>>
>>> Yes, and when sendPageAndWait returns the calling blocks flow
>>> continues with a new account accessible from the session. Maybe we
>>> need a new method such as callFunction.
>> sorry, guys ...you've lost me here.
>> I don't get the problem.
>
> Do you refer to the paragraph above or the complete discussion? (I
> don't understand what Glen is talking about either.)
LOL. Basicly, you just need to have the foreign flowscript do its job.
Results can either be returned directly or placed in the Session. It
shouldn't be that big a deal.
>
> I think Daniel's explanation makes sense - only needs somebody who has
> time to try it out ;-)
>
>> Btw: while working on the javaflow
>> stuff I felt a very strong urge to
>> refactor the sitemap-flow interface.
>> (see the JavaInterpreter in the
>> javaflow block. I've put a revisit
>> into the callFunction method)
>
> I see ... If you come up with a better interface we could take the
> chance that 2.2 isn't out now and deprecate the old syntax in 2.2.
>
> --
> Reinhard
>
>
>
Glen Ezkovich
HardBop Consulting
glen at hard-bop.com
http://www.hard-bop.com
A Proverb for Paranoids:
"If they can get you asking the wrong questions, they don't have to
worry about answers."
- Thomas Pynchon Gravity's Rainbow
Re: Blocks, Flow and Dependencies [was RE: Splitting xconf files
step 2: the sitemap]
Posted by Reinhard Poetz <re...@apache.org>.
Torsten Curdt wrote:
>>>> So it seems, flow replaces components? If createNewAccount() gathers
>>>> sends pages, collects information, creates an Account, etc. then why
>>>> not just use cocoon.sendPageAndWait?
>>>
>>>
>>>
>>> because this is done in the called block, not by the callee.
>>
>>
>>
>> Yes, and when sendPageAndWait returns the calling blocks flow
>> continues with a new account accessible from the session. Maybe we
>> need a new method such as callFunction.
>
>
> sorry, guys ...you've lost me here.
> I don't get the problem.
Do you refer to the paragraph above or the complete discussion? (I don't
understand what Glen is talking about either.)
I think Daniel's explanation makes sense - only needs somebody who has time to
try it out ;-)
>
> Btw: while working on the javaflow
> stuff I felt a very strong urge to
> refactor the sitemap-flow interface.
>
> (see the JavaInterpreter in the
> javaflow block. I've put a revisit
> into the callFunction method)
I see ... If you come up with a better interface we could take the chance that
2.2 isn't out now and deprecate the old syntax in 2.2.
--
Reinhard
Re: Blocks, Flow and Dependencies [was RE: Splitting xconf files step 2: the sitemap]
Posted by Glen Ezkovich <gl...@hard-bop.com>.
On Jan 11, 2005, at 3:57 AM, Torsten Curdt wrote:
>
> k ...then I did understand correctly.
> the "callFunction" proposal got me
> a bit off the track ;)
>
I seem to be good at that. Since it was not something that I seriously
support, I will refrain from explaining. ;P
Glen Ezkovich
HardBop Consulting
glen at hard-bop.com
http://www.hard-bop.com
A Proverb for Paranoids:
"If they can get you asking the wrong questions, they don't have to
worry about answers."
- Thomas Pynchon Gravity's Rainbow
Re: Blocks, Flow and Dependencies [was RE: Splitting xconf files
step 2: the sitemap]
Posted by Torsten Curdt <tc...@apache.org>.
>> ok ...what version of javascript does
>> rhino implement? I could not find that
>> information...
>
>
> http://www.mozilla.org/rhino/overview.html
> (in trunk we use Rhino 1.6pre1)
bummer ...must have missed that one
ok ...so 1.5 it is
cheers
--
Torsten
Re: Blocks,
Flow and Dependencies [was RE: Splitting xconf filesstep 2: the
sitemap]
Posted by Antonio Gallardo <ag...@agssa.net>.
On Mar, 11 de Enero de 2005, 4:07, Reinhard Poetz dijo:
> http://www.mozilla.org/rhino/overview.html
> (in trunk we use Rhino 1.6pre1)
Nope, we are using rhino 1.6R1:
http://svn.apache.org/viewcvs.cgi/cocoon/trunk/lib/core/rhino-1.6R1.jar?rev=123652&view=log
Anyway it is javascript 1.5.
Best Regards,
Antonio Gallardo
Re: Blocks, Flow and Dependencies [was RE: Splitting xconf files
step 2: the sitemap]
Posted by Reinhard Poetz <re...@apache.org>.
Torsten Curdt wrote:
>> that's the goal. But with imports in <map:flow/> you will get into
>> trouble:
>>
>> <map:flow>
>> <map:script src="block:blockA/flow.js"/>
>> <map:script src="block:blockB/flow.js"/>
>> <map:script src="flow.js"/>
>> </map:flow>
>>
>> In this case print(blockBFunc()); will return "A".
>
>
> k ...then I did understand correctly.
> the "callFunction" proposal got me
> a bit off the track ;)
>
>>> But there is only one helper() method per block!?
>>
>>
>>
>> Yes. Therefore we need something more sohpisticated than imports.
>
>
> ok ...what version of javascript does
> rhino implement? I could not find that
> information...
http://www.mozilla.org/rhino/overview.html
(in trunk we use Rhino 1.6pre1)
--
Reinhard
Re: Blocks, Flow and Dependencies [was RE: Splitting xconf files
step 2: the sitemap]
Posted by Torsten Curdt <tc...@apache.org>.
> that's the goal. But with imports in <map:flow/> you will get into
> trouble:
>
> <map:flow>
> <map:script src="block:blockA/flow.js"/>
> <map:script src="block:blockB/flow.js"/>
> <map:script src="flow.js"/>
> </map:flow>
>
> In this case print(blockBFunc()); will return "A".
k ...then I did understand correctly.
the "callFunction" proposal got me
a bit off the track ;)
>> But there is only one helper() method per block!?
>
>
> Yes. Therefore we need something more sohpisticated than imports.
ok ...what version of javascript does
rhino implement? I could not find that
information...
cheers
--
Torsten
Re: Blocks, Flow and Dependencies [was RE: Splitting xconf files step 2: the sitemap]
Posted by Glen Ezkovich <gl...@hard-bop.com>.
On Jan 15, 2005, at 12:57 PM, Stefano Mazzocchi wrote:
> Glen Ezkovich wrote:
>> On Jan 14, 2005, at 2:38 PM, Stefano Mazzocchi wrote:
>>>>
>>>
>>> Good luck! :-)
>>>
>>> And in case you emerge back from the sea of email alive and you feel
>>> like writing a summary, I'm sure a lot of people will love you for
>>> that eheh :-)
>> Or hate me ;-)
>
> for some philosophers there is no difference in the two anyway ;-)
As the solipsist that I am, it makes no difference. This list is just
my way of arguing with myself. ;-O
Glen Ezkovich
HardBop Consulting
glen at hard-bop.com
http://www.hard-bop.com
A Proverb for Paranoids:
"If they can get you asking the wrong questions, they don't have to
worry about answers."
- Thomas Pynchon Gravity's Rainbow
Re: Blocks, Flow and Dependencies [was RE: Splitting xconf files
step 2: the sitemap]
Posted by Stefano Mazzocchi <st...@apache.org>.
Glen Ezkovich wrote:
>
> On Jan 14, 2005, at 2:38 PM, Stefano Mazzocchi wrote:
>
>>>
>>
>> Good luck! :-)
>>
>> And in case you emerge back from the sea of email alive and you feel
>> like writing a summary, I'm sure a lot of people will love you for
>> that eheh :-)
>
> Or hate me ;-)
for some philosophers there is no difference in the two anyway ;-)
--
Stefano.
Re: Blocks, Flow and Dependencies [was RE: Splitting xconf files step 2: the sitemap]
Posted by Glen Ezkovich <gl...@hard-bop.com>.
On Jan 14, 2005, at 2:38 PM, Stefano Mazzocchi wrote:
>>
>
> Good luck! :-)
>
> And in case you emerge back from the sea of email alive and you feel
> like writing a summary, I'm sure a lot of people will love you for
> that eheh :-)
Or hate me ;-)
>
> --
> Stefano.
>
>
>
>
Glen Ezkovich
HardBop Consulting
glen at hard-bop.com
http://www.hard-bop.com
A Proverb for Paranoids:
"If they can get you asking the wrong questions, they don't have to
worry about answers."
- Thomas Pynchon Gravity's Rainbow
Re: Blocks, Flow and Dependencies [was RE: Splitting xconf files
step 2: the sitemap]
Posted by Stefano Mazzocchi <st...@apache.org>.
Glen Ezkovich wrote:
>
> On Jan 13, 2005, at 6:53 PM, Stefano Mazzocchi wrote:
>
>> Glen Ezkovich wrote:
>>
>>> By the way, I'm curious what you think about making a block's
>>> resources available. There are two conflicting wiki pages.
>>> there is this
>>>
>>>> A block exposes a sitemap and Avalon Components (both optionally)
>>>
>>> from http://wiki.apache.org/cocoon/GT2003RealBlocks
>>> and this
>>>
>>>> A block exposes two types of services:
>>>> ▪ components
>>>> ▪ resources
>>>> ▪ pipelines ??
>>>
>>> from http://wiki.apache.org/cocoon/BlocksDefinition
>>> the second of which gives the following as an example of accessing a
>>> resource.
>>>
>>>> block:skin:/stylesheets/document2html.xslt
>>
>>
>> that's outdated. I started off the design thinking that blocks should
>> expose resources, but then Sylvain convinced us that this was just
>> going to create some problems because at that point you need two
>> different protocols one to identify the file space and the other to
>> indentify the URL space.
>>
>> So, if you want to access a resource, use a reader on your sitemap and
>> you unify the approach (note that performance wise this is not a
>> problem since the caches run in between all this).
>
>
> Thanks for clarifying this. Its good to know the reason for the
> decision. I think I will try to see what I can find in the archives and
> get up to full speed on the discussions that have shaped the current
> state of the groups understanding of blocks.
Good luck! :-)
And in case you emerge back from the sea of email alive and you feel
like writing a summary, I'm sure a lot of people will love you for that
eheh :-)
--
Stefano.
Re: Blocks, Flow and Dependencies [was RE: Splitting xconf files step 2: the sitemap]
Posted by Glen Ezkovich <gl...@hard-bop.com>.
On Jan 13, 2005, at 6:53 PM, Stefano Mazzocchi wrote:
> Glen Ezkovich wrote:
>
>> By the way, I'm curious what you think about making a block's
>> resources available. There are two conflicting wiki pages.
>> there is this
>>> A block exposes a sitemap and Avalon Components (both
>>> optionally)
>> from http://wiki.apache.org/cocoon/GT2003RealBlocks
>> and this
>>> A block exposes two types of services:
>>> ▪ components
>>> ▪ resources
>>> ▪ pipelines ??
>> from http://wiki.apache.org/cocoon/BlocksDefinition
>> the second of which gives the following as an example of accessing a
>> resource.
>>> block:skin:/stylesheets/document2html.xslt
>
> that's outdated. I started off the design thinking that blocks should
> expose resources, but then Sylvain convinced us that this was just
> going to create some problems because at that point you need two
> different protocols one to identify the file space and the other to
> indentify the URL space.
>
> So, if you want to access a resource, use a reader on your sitemap and
> you unify the approach (note that performance wise this is not a
> problem since the caches run in between all this).
Thanks for clarifying this. Its good to know the reason for the
decision. I think I will try to see what I can find in the archives and
get up to full speed on the discussions that have shaped the current
state of the groups understanding of blocks.
Glen Ezkovich
HardBop Consulting
glen at hard-bop.com
http://www.hard-bop.com
A Proverb for Paranoids:
"If they can get you asking the wrong questions, they don't have to
worry about answers."
- Thomas Pynchon Gravity's Rainbow
Re: Blocks, Flow and Dependencies [was RE: Splitting xconf files
step 2: the sitemap]
Posted by Stefano Mazzocchi <st...@apache.org>.
Glen Ezkovich wrote:
> By the way, I'm curious what you think about making a block's resources
> available. There are two conflicting wiki pages.
>
> there is this
>
>> A block exposes a sitemap and Avalon Components (both optionally)
>
> from http://wiki.apache.org/cocoon/GT2003RealBlocks
>
> and this
>
>> A block exposes two types of services:
>> ▪ components
>> ▪ resources
>> ▪ pipelines ??
>
> from http://wiki.apache.org/cocoon/BlocksDefinition
>
> the second of which gives the following as an example of accessing a
> resource.
>
>> block:skin:/stylesheets/document2html.xslt
that's outdated. I started off the design thinking that blocks should
expose resources, but then Sylvain convinced us that this was just going
to create some problems because at that point you need two different
protocols one to identify the file space and the other to indentify the
URL space.
So, if you want to access a resource, use a reader on your sitemap and
you unify the approach (note that performance wise this is not a problem
since the caches run in between all this).
--
Stefano.
Re: Blocks, Flow and Dependencies [was RE: Splitting xconf files step 2: the sitemap]
Posted by Glen Ezkovich <gl...@hard-bop.com>.
On Jan 12, 2005, at 4:53 PM, Stefano Mazzocchi wrote:
> Glen Ezkovich wrote:
>> After rereading much of this discussion and the various wiki pages
>> concerning blocks I withdraw almost everything I said. Its now
>> obvious to me that the way to achieve everything we are talking about
>> is to allow for multiple inheritance. I am not recommending this
>> since I have not thought deeply about its implications yet.
>> Generally, I don't like multiple inheritance.
>> The reason I even bring this up is that it seems clear that there are
>> two different ways we may want to use a block. One way is to just
>> simply use a block through its sitemap and/or components it exposes.
>> That is use one of its pipelines, VPCs or components directly from
>> another block. The other way is to compose an application by
>> combining several blocks. By using the extension mechanism you just
>> need to override default configuration and other resource files to
>> customize your application. For example we may put an e-commerce app
>> together by combining authentication, shopping cart, store, shipping
>> and webmail blocks. Because each of these blocks may have different
>> looks and feels I may want to make sure that our app has a consistent
>> L&F by overriding a few resources in each of those blocks. Likewise I
>> may need to alter the checkout flow and can do so by overriding a
>> single resource. This by far will be the easiest way to compose the
>> app out of the various blocks and does not require hacks to the
>> sitemap or any complex URI machinations by the developer.
>> How this for adding fuel to the fire. Ok... now you can tie me to a
>> log and just toss me on top.
>
> Glen,
>
> I've thought deep and hard about the 'composition' patterns that real
> block should need and I realized that it's inherently bad practice to
> allow something without knowning how harmful it might be.
>
> So, I would suggest we use the good old approach: keep it simple and
> add functionality only if somebody has enough itches to scratch.
>
> In fact, real block alltogether might be overdesign, who knows.
I doubt that, but I think you may want to limit its scope initially.
>
> If we got to implement what we already achieved consensus upon would
> be a great start. Not the end of reasearch in higher-order webapp
> composition patterns :-)
>
I agree completely. I just threw this out as a possible simplification
from a user perspective. I am a firm believer in developing
incrementally. Obviously, simple extension comes first. The problems
that led to this thread should not be solved before we have basic
blocks working.
By the way, I'm curious what you think about making a block's resources
available. There are two conflicting wiki pages.
there is this
> A block exposes a sitemap and Avalon Components (both optionally)
from http://wiki.apache.org/cocoon/GT2003RealBlocks
and this
> A block exposes two types of services:
> ▪ components
> ▪ resources
> ▪ pipelines ??
from http://wiki.apache.org/cocoon/BlocksDefinition
the second of which gives the following as an example of accessing a
resource.
> block:skin:/stylesheets/document2html.xslt
Glen Ezkovich
HardBop Consulting
glen at hard-bop.com
http://www.hard-bop.com
A Proverb for Paranoids:
"If they can get you asking the wrong questions, they don't have to
worry about answers."
- Thomas Pynchon Gravity's Rainbow
Re: Blocks, Flow and Dependencies [was RE: Splitting xconf files
step 2: the sitemap]
Posted by Stefano Mazzocchi <st...@apache.org>.
Glen Ezkovich wrote:
> After rereading much of this discussion and the various wiki pages
> concerning blocks I withdraw almost everything I said. Its now obvious
> to me that the way to achieve everything we are talking about is to
> allow for multiple inheritance. I am not recommending this since I have
> not thought deeply about its implications yet. Generally, I don't like
> multiple inheritance.
>
> The reason I even bring this up is that it seems clear that there are
> two different ways we may want to use a block. One way is to just simply
> use a block through its sitemap and/or components it exposes. That is
> use one of its pipelines, VPCs or components directly from another
> block. The other way is to compose an application by combining several
> blocks. By using the extension mechanism you just need to override
> default configuration and other resource files to customize your
> application. For example we may put an e-commerce app together by
> combining authentication, shopping cart, store, shipping and webmail
> blocks. Because each of these blocks may have different looks and feels
> I may want to make sure that our app has a consistent L&F by overriding
> a few resources in each of those blocks. Likewise I may need to alter
> the checkout flow and can do so by overriding a single resource. This
> by far will be the easiest way to compose the app out of the various
> blocks and does not require hacks to the sitemap or any complex URI
> machinations by the developer.
>
> How this for adding fuel to the fire. Ok... now you can tie me to a log
> and just toss me on top.
Glen,
I've thought deep and hard about the 'composition' patterns that real
block should need and I realized that it's inherently bad practice to
allow something without knowning how harmful it might be.
So, I would suggest we use the good old approach: keep it simple and add
functionality only if somebody has enough itches to scratch.
In fact, real block alltogether might be overdesign, who knows.
If we got to implement what we already achieved consensus upon would be
a great start. Not the end of reasearch in higher-order webapp
composition patterns :-)
--
Stefano.
Re: Blocks, Flow and Dependencies [was RE: Splitting xconf files step 2: the sitemap]
Posted by Glen Ezkovich <gl...@hard-bop.com>.
After rereading much of this discussion and the various wiki pages
concerning blocks I withdraw almost everything I said. Its now obvious
to me that the way to achieve everything we are talking about is to
allow for multiple inheritance. I am not recommending this since I have
not thought deeply about its implications yet. Generally, I don't like
multiple inheritance.
The reason I even bring this up is that it seems clear that there are
two different ways we may want to use a block. One way is to just
simply use a block through its sitemap and/or components it exposes.
That is use one of its pipelines, VPCs or components directly from
another block. The other way is to compose an application by combining
several blocks. By using the extension mechanism you just need to
override default configuration and other resource files to customize
your application. For example we may put an e-commerce app together by
combining authentication, shopping cart, store, shipping and webmail
blocks. Because each of these blocks may have different looks and feels
I may want to make sure that our app has a consistent L&F by overriding
a few resources in each of those blocks. Likewise I may need to alter
the checkout flow and can do so by overriding a single resource. This
by far will be the easiest way to compose the app out of the various
blocks and does not require hacks to the sitemap or any complex URI
machinations by the developer.
How this for adding fuel to the fire. Ok... now you can tie me to a log
and just toss me on top.
Glen Ezkovich
HardBop Consulting
glen at hard-bop.com
http://www.hard-bop.com
A Proverb for Paranoids:
"If they can get you asking the wrong questions, they don't have to
worry about answers."
- Thomas Pynchon Gravity's Rainbow
Re: Blocks, Flow and Dependencies
Posted by Reinhard Poetz <re...@apache.org>.
Daniel Fagerstrom wrote:
> Stefano Mazzocchi wrote:
>
>> Reinhard Poetz wrote:
>>
>>>>> Answer: It depends on the order of declaring your scripts in
>>>>> <map:flow/>. The first helper() method declared will be found.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> But there is only one helper() method per block!?
>>>
>>>
>>>
>>>
>>> Yes. Therefore we need something more sohpisticated than imports.
>>
>>
>>
>> I'm having a hard time following this conversation, as it seems to me
>> that this is another instance of something that is becoming an
>> anti-pattern: "stating the solution before stating the problem".
I agree but as Daniel explains below, we first had the problem. Maybe you gave
them a better headline (delegation) and you found a second problem problem that
could be relevant in this context: extension
> The problem that we discuss was stated by Reinhard in
> http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=110519369529959&w=2,
> and then discussed in the rest of that thread
> (http://marc.theaimsgroup.com/?t=110467878200001&r=1&w=2). Glen changed
> name of the thread to something more relevant for the topic and we
> continued to discuss it
> http://marc.theaimsgroup.com/?t=110533379600002&r=1&w=2. I tried to
> explain the issues and point to the use case in
> http://marc.theaimsgroup.com/?t=110533379600002&r=1&w=2 again, as a
> service to newcommers to the discussion, and make a new trial explaining
> the issues below.
>
>> The problem is that you want to use some functionality defined in
>> another block.
>>
>> Fair enough, since that's what blocks are: isolated service providers.
>>
>> One of the design decisions with blocks is that *NO FILE* will ever be
>> exposed by the blocks directly.
>>
>> There is practically no way in the world you are going to change my
>> mind on that, so consider it a permanent -1 for a block to expose
>> direct file access.
>
>
> I agree completely with that, and have discussed how to achieve
> shielding of block internals earlier in the thread.
>
> Usecase
> =======
>
> Now the use case that Reinhard and I have discussed is:
>
> The idea is that I in a number of my webapps want to use the same
> handling of new customers. And therefore I have written a block
> "Customer" containing among other things a flowscript function:
>
> function newCustomer() {
> var customer = new Customer(defaultCustomer.xml);
> cocoon.sendPageAndWait("nameAndAdress");
> ...
> cocoon.sendPageAndWait("preferences");
> ...
> cocoon.sendPageAndWait("spamPreferenses");
> ...
> return customer;
> }
>
> That handles a dialog with a new customer and returns an object that
> contains the result of the interaction.
>
> Then we might want to use this functionality in another block for
> e-business that among other things uses the newCustomer function. That
> could e.g. look like:
>
> function buy() {
> ...
> var customer = newCustomer();
> ...
> cocoon.sendPageAndWait("shoppingCart");
> ...
> }
>
> IMO this is a relevant use case for blocks and flow.
>
> Several Contexts
> ================
>
> After having seen the use case the question is what to do about it.
> First it is important to note that Customer:newCustomer() contain a
> number of references to resources within the Customer block: the file
> defaultCustomer.xml and the possibly internal pipelines nameAndAdress,
> preferences, spamPreferenses. A consequence of this is that even if the
> function is executed in the context of another block, like the
> e-business block above, all its relative URIs must be resolved in the
> context of the Customer block.
>
> So using flowscripts from other blocks is more complicated that using
> flowscripts from the same block (the current situation). When using a
> flowscript from the same block you just call it in the current context
> that is descripbed by the FOM. When you use a flowscript from another
> block it must be exectuted in the context of the "FOM" from the other
> block. So the situation is like in object oriented programing the block
> is an object and the flowscript function is a method on it.
>
> Sylvain have recoginzed that the handling of block (and sitemap)
> specific contexts is necessary for implementing VPCs and blocks, and
> discussed the concepts and its implementation in
> http://marc.theaimsgroup.com/?t=110064560900003&r=1&w=2. I have sugested
> that this can be interpreted in terms of static and dynamic binding, a
> refinement of the parameter passing strategy and polymorphic sitemaps in
> that thread.
>
> Implementation Approaches
> =========================
>
> Returning to implementation of the usecase above. We have discussed some
> solutions, it can be solved by calling the flowscript function in a VPC
> pipeline defined in block. This VPC pipeline can then be used in other
> places following Sylvains design. We need some slightly modificated
> cocoon.sendPageAndWait function that handles foreign VPCs. This is the
> solution that I initially and Glen more persistently proposed.
>
> The problem with that solution is how to pass the return value. It could
> be done by seting a session variable from the flowscript variable, but
> neither I nor Reinhard liked that solution. Communication between
> components by using global variables is not my favorite way of building
> systems. It scales badly, the communication between components becomes
> rather implicit and we have a risk that different blocks gets session
> variable name collisions.
>
> Another solution would be to introduce some kind of return value for VPC
> pipelines and a third would be package the exported flowscript function
> as some function like thing that is easy to use from flowscripts.
> Reinhard and I have discussed the third option.
>
> Here there are a number of questions:
>
> * How to export functions from blocks. My opinion is that they should be
> explicitly enumerated in the VPC section is the block
>
> * How to use them from another block, provided that they are exported.
> Reihnard proposed: cocoon.block.Customer.newCustomer();, which I find a
> good solution as it solves the problem that the function must be called
> in the context of its block. It solves the problem with lack of name
> spaces in JS and it also showes the object oriented nature of the
> situation.
>
> * How to implement it.
>
> * Other shielding issues. E.g. what about the web continuations that are
> created during the execution of a block flowscript:
> http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=110537204229024&w=2
>
> --- o0o ---
>
>> Blocks *may* expose their sitemap pipelines but nobody said that they
>> couldn't expose flow functions too (which are the flow equivalent of
>> sitemap pipelines)
>>
>> Now, blocks have different composition patterns:
>>
>> - dependency
>> - extension
>>
>> the two will, IMO, result in different ways of composing flow functions.
>>
>> Dependency can make available, either implicity or explicitly thru a
>> cocoon.importDependencies() the block's dependencies.
>>
>> Since javascript has no notion of "private/public" for functions, we
>> could specify that functions that start with _ are "private", while
>> the other ones are "public". Or something like that.
>>
>> For extension, we could have automatic overload, so that if block A
>> has flow with function blah() and block B extends block A with
>> function blah() you can do
>>
>> block b:
>> blah() {
>> cocoon.super()
>> print "blah b"
>> }
>>
>> block a:
>> blah() {
>> print "blah a"
>> }
>>
>> if block b extends block a, calling blah() on b will result in
>>
>> blah a
>> blah b
>
>
> These are certainly also important use cases.
>
>> There is *NO* need for direct file access and there is
>
>
> Agree
>
>> *NO* need for namespaces in javascript.
>
>
> Combining blocks from several manufacturers will be more complicated if
> there are name collsions. But by using the exported functions as a
> method on the "block object", that problem disapears.
>
>> I understand the above might not be easy to implement, but
>> implementation difficulty should *never* drive design decisions.
>
>
> I tend to live after that policy, but my employers have not always been
> happy with that approach ;)
;-)
I think this mail is a very good summary of the current status of our discussion
about how inter-block flowscript communication should look like.
--
Reinhard
Re: Blocks, Flow and Dependencies [was RE: Splitting xconf files
step 2: the sitemap]
Posted by Daniel Fagerstrom <da...@nada.kth.se>.
Stefano Mazzocchi wrote:
> Reinhard Poetz wrote:
>
>>>> Answer: It depends on the order of declaring your scripts in
>>>> <map:flow/>. The first helper() method declared will be found.
>>>
>>>
>>>
>>>
>>> But there is only one helper() method per block!?
>>
>>
>>
>> Yes. Therefore we need something more sohpisticated than imports.
>
>
> I'm having a hard time following this conversation, as it seems to me
> that this is another instance of something that is becoming an
> anti-pattern: "stating the solution before stating the problem".
The problem that we discuss was stated by Reinhard in
http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=110519369529959&w=2,
and then discussed in the rest of that thread
(http://marc.theaimsgroup.com/?t=110467878200001&r=1&w=2). Glen changed
name of the thread to something more relevant for the topic and we
continued to discuss it
http://marc.theaimsgroup.com/?t=110533379600002&r=1&w=2. I tried to
explain the issues and point to the use case in
http://marc.theaimsgroup.com/?t=110533379600002&r=1&w=2 again, as a
service to newcommers to the discussion, and make a new trial explaining
the issues below.
> The problem is that you want to use some functionality defined in
> another block.
>
> Fair enough, since that's what blocks are: isolated service providers.
>
> One of the design decisions with blocks is that *NO FILE* will ever be
> exposed by the blocks directly.
>
> There is practically no way in the world you are going to change my
> mind on that, so consider it a permanent -1 for a block to expose
> direct file access.
I agree completely with that, and have discussed how to achieve
shielding of block internals earlier in the thread.
Usecase
=======
Now the use case that Reinhard and I have discussed is:
The idea is that I in a number of my webapps want to use the same
handling of new customers. And therefore I have written a block
"Customer" containing among other things a flowscript function:
function newCustomer() {
var customer = new Customer(defaultCustomer.xml);
cocoon.sendPageAndWait("nameAndAdress");
...
cocoon.sendPageAndWait("preferences");
...
cocoon.sendPageAndWait("spamPreferenses");
...
return customer;
}
That handles a dialog with a new customer and returns an object that
contains the result of the interaction.
Then we might want to use this functionality in another block for
e-business that among other things uses the newCustomer function. That
could e.g. look like:
function buy() {
...
var customer = newCustomer();
...
cocoon.sendPageAndWait("shoppingCart");
...
}
IMO this is a relevant use case for blocks and flow.
Several Contexts
================
After having seen the use case the question is what to do about it.
First it is important to note that Customer:newCustomer() contain a
number of references to resources within the Customer block: the file
defaultCustomer.xml and the possibly internal pipelines nameAndAdress,
preferences, spamPreferenses. A consequence of this is that even if the
function is executed in the context of another block, like the
e-business block above, all its relative URIs must be resolved in the
context of the Customer block.
So using flowscripts from other blocks is more complicated that using
flowscripts from the same block (the current situation). When using a
flowscript from the same block you just call it in the current context
that is descripbed by the FOM. When you use a flowscript from another
block it must be exectuted in the context of the "FOM" from the other
block. So the situation is like in object oriented programing the block
is an object and the flowscript function is a method on it.
Sylvain have recoginzed that the handling of block (and sitemap)
specific contexts is necessary for implementing VPCs and blocks, and
discussed the concepts and its implementation in
http://marc.theaimsgroup.com/?t=110064560900003&r=1&w=2. I have sugested
that this can be interpreted in terms of static and dynamic binding, a
refinement of the parameter passing strategy and polymorphic sitemaps in
that thread.
Implementation Approaches
=========================
Returning to implementation of the usecase above. We have discussed some
solutions, it can be solved by calling the flowscript function in a VPC
pipeline defined in block. This VPC pipeline can then be used in other
places following Sylvains design. We need some slightly modificated
cocoon.sendPageAndWait function that handles foreign VPCs. This is the
solution that I initially and Glen more persistently proposed.
The problem with that solution is how to pass the return value. It could
be done by seting a session variable from the flowscript variable, but
neither I nor Reinhard liked that solution. Communication between
components by using global variables is not my favorite way of building
systems. It scales badly, the communication between components becomes
rather implicit and we have a risk that different blocks gets session
variable name collisions.
Another solution would be to introduce some kind of return value for VPC
pipelines and a third would be package the exported flowscript function
as some function like thing that is easy to use from flowscripts.
Reinhard and I have discussed the third option.
Here there are a number of questions:
* How to export functions from blocks. My opinion is that they should be
explicitly enumerated in the VPC section is the block
* How to use them from another block, provided that they are exported.
Reihnard proposed: cocoon.block.Customer.newCustomer();, which I find a
good solution as it solves the problem that the function must be called
in the context of its block. It solves the problem with lack of name
spaces in JS and it also showes the object oriented nature of the situation.
* How to implement it.
* Other shielding issues. E.g. what about the web continuations that are
created during the execution of a block flowscript:
http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=110537204229024&w=2
--- o0o ---
> Blocks *may* expose their sitemap pipelines but nobody said that they
> couldn't expose flow functions too (which are the flow equivalent of
> sitemap pipelines)
>
> Now, blocks have different composition patterns:
>
> - dependency
> - extension
>
> the two will, IMO, result in different ways of composing flow functions.
>
> Dependency can make available, either implicity or explicitly thru a
> cocoon.importDependencies() the block's dependencies.
>
> Since javascript has no notion of "private/public" for functions, we
> could specify that functions that start with _ are "private", while
> the other ones are "public". Or something like that.
>
> For extension, we could have automatic overload, so that if block A
> has flow with function blah() and block B extends block A with
> function blah() you can do
>
> block b:
> blah() {
> cocoon.super()
> print "blah b"
> }
>
> block a:
> blah() {
> print "blah a"
> }
>
> if block b extends block a, calling blah() on b will result in
>
> blah a
> blah b
These are certainly also important use cases.
> There is *NO* need for direct file access and there is
Agree
> *NO* need for namespaces in javascript.
Combining blocks from several manufacturers will be more complicated if
there are name collsions. But by using the exported functions as a
method on the "block object", that problem disapears.
> I understand the above might not be easy to implement, but
> implementation difficulty should *never* drive design decisions.
I tend to live after that policy, but my employers have not always been
happy with that approach ;)
--- o0o ---
HTH
/Daniel
Re: Blocks, Flow and Dependencies [was RE: Splitting xconf files step 2: the sitemap]
Posted by Glen Ezkovich <gl...@hard-bop.com>.
I really hate to say anything about this but ...
On Jan 11, 2005, at 8:57 AM, Stefano Mazzocchi wrote:
> Reinhard Poetz wrote:
>
>>>> Answer: It depends on the order of declaring your scripts in
>>>> <map:flow/>. The first helper() method declared will be found.
>>>
>>>
>>>
>>> But there is only one helper() method per block!?
>> Yes. Therefore we need something more sohpisticated than imports.
>
> I'm having a hard time following this conversation, as it seems to me
> that this is another instance of something that is becoming an
> anti-pattern: "stating the solution before stating the problem".
Agreed.
>
> The problem is that you want to use some functionality defined in
> another block.
>
> Fair enough, since that's what blocks are: isolated service providers.
>
> One of the design decisions with blocks is that *NO FILE* will ever be
> exposed by the blocks directly.
I took this to mean through the file system directly. I believe in all
my examples I used a block pseudo protocol to locate the javascript
file.
>
> There is practically no way in the world you are going to change my
> mind on that, so consider it a permanent -1 for a block to expose
> direct file access.
>
> Blocks *may* expose their sitemap pipelines but nobody said that they
> couldn't expose flow functions too (which are the flow equivalent of
> sitemap pipelines)
I think the issue was how they would expose these functions. I see it
as a relatively simple matter of block configuration, loading the
functions and designing the functions properly for use by other blocks.
If the javascript functions were not intended for this purpose they
should not be exposed.
>
> Now, blocks have different composition patterns:
>
> - dependency
> - extension
Do you mean 2 types of dependency, composition and extension?
>
> the two will, IMO, result in different ways of composing flow
> functions.
>
> Dependency can make available, either implicity or explicitly thru a
> cocoon.importDependencies() the block's dependencies.
I don't understand what you mean here. Do you mean that, say in the
flowscript instead of using load we use importDependencies defined in
the blocks configuration?
>
> Since javascript has no notion of "private/public" for functions, we
> could specify that functions that start with _ are "private", while
> the other ones are "public". Or something like that.
it works for me, but is this an issue we can solve or does this depend
on Rhino?
>
> For extension, we could have automatic overload, so that if block A
> has flow with function blah() and block B extends block A with
> function blah() you can do
>
> block b:
> blah() {
> cocoon.super()
> print "blah b"
> }
>
> block a:
> blah() {
> print "blah a"
> }
>
> if block b extends block a, calling blah() on b will result in
>
> blah a
> blah b
Since when does javascript have an extension mechanism? Are you sure
this is necessary or even a good idea. If you wish to use extension and
overloading use Java flow.
>
> There is *NO* need for direct file access and there is *NO* need for
> namespaces in javascript.
umm.. packages would be nice ;-) One of the many reasons I hope to
convert to Java flow.
>
> I understand the above might not be easy to implement, but
> implementation difficulty should *never* drive design decisions.
This isn't about design its about functionality. Its about what one
should be able to do with javascript functions defined in a foreign
block. The design you are talking about here is designing an extension
hack for javascript, not an architectural design of the system that
implements it. In this case difficulty should play a role in the
decision on whether to attempt this.
>
> --
> Stefano.
>
>
>
>
Glen Ezkovich
HardBop Consulting
glen at hard-bop.com
http://www.hard-bop.com
A Proverb for Paranoids:
"If they can get you asking the wrong questions, they don't have to
worry about answers."
- Thomas Pynchon Gravity's Rainbow
Re: Blocks, Flow and Dependencies [was RE: Splitting xconf files
step 2: the sitemap]
Posted by Stefano Mazzocchi <st...@apache.org>.
Reinhard Poetz wrote:
>>> Answer: It depends on the order of declaring your scripts in
>>> <map:flow/>. The first helper() method declared will be found.
>>
>>
>>
>> But there is only one helper() method per block!?
>
>
> Yes. Therefore we need something more sohpisticated than imports.
I'm having a hard time following this conversation, as it seems to me
that this is another instance of something that is becoming an
anti-pattern: "stating the solution before stating the problem".
The problem is that you want to use some functionality defined in
another block.
Fair enough, since that's what blocks are: isolated service providers.
One of the design decisions with blocks is that *NO FILE* will ever be
exposed by the blocks directly.
There is practically no way in the world you are going to change my mind
on that, so consider it a permanent -1 for a block to expose direct file
access.
Blocks *may* expose their sitemap pipelines but nobody said that they
couldn't expose flow functions too (which are the flow equivalent of
sitemap pipelines)
Now, blocks have different composition patterns:
- dependency
- extension
the two will, IMO, result in different ways of composing flow functions.
Dependency can make available, either implicity or explicitly thru a
cocoon.importDependencies() the block's dependencies.
Since javascript has no notion of "private/public" for functions, we
could specify that functions that start with _ are "private", while the
other ones are "public". Or something like that.
For extension, we could have automatic overload, so that if block A has
flow with function blah() and block B extends block A with function
blah() you can do
block b:
blah() {
cocoon.super()
print "blah b"
}
block a:
blah() {
print "blah a"
}
if block b extends block a, calling blah() on b will result in
blah a
blah b
There is *NO* need for direct file access and there is *NO* need for
namespaces in javascript.
I understand the above might not be easy to implement, but
implementation difficulty should *never* drive design decisions.
--
Stefano.
Re: Blocks, Flow and Dependencies [was RE: Splitting xconf files
step 2: the sitemap]
Posted by Reinhard Poetz <re...@apache.org>.
Torsten Curdt wrote:
>> Problem:
>>
>> flow.js of blockA
>> ------------------
>> function blockAFunc() {
>> return helper();
>> }
>> function helper() {
>> return "A";
>> }
>>
>> flow.js of blockB
>> -----------------
>> function blockBFunc() {
>> return helper();
>> }
>> function helper() {
>> return "B";
>> }
>>
>>
>> flow.js of blockC
>> -----------------
>> function blockCFunc() {
>> print(blockB());
>
>
> You mean:
>
> print(blockBFunc());
sorry, yes
>> }
>>
>> What do you expect when you call blockCFun()? A or B?
>
>
> Sorry, for the late response
>
> ...but clearly: B
that's the goal. But with imports in <map:flow/> you will get into trouble:
<map:flow>
<map:script src="block:blockA/flow.js"/>
<map:script src="block:blockB/flow.js"/>
<map:script src="flow.js"/>
</map:flow>
In this case print(blockBFunc()); will return "A".
>
>> Answer: It depends on the order of declaring your scripts in
>> <map:flow/>. The first helper() method declared will be found.
>
>
> But there is only one helper() method per block!?
Yes. Therefore we need something more sohpisticated than imports.
--
Reinhard
Re: Blocks, Flow and Dependencies [was RE: Splitting xconf files
step 2: the sitemap]
Posted by Torsten Curdt <tc...@apache.org>.
> Problem:
>
> flow.js of blockA
> ------------------
> function blockAFunc() {
> return helper();
> }
> function helper() {
> return "A";
> }
>
> flow.js of blockB
> -----------------
> function blockBFunc() {
> return helper();
> }
> function helper() {
> return "B";
> }
>
>
> flow.js of blockC
> -----------------
> function blockCFunc() {
> print(blockB());
You mean:
print(blockBFunc());
> }
>
> What do you expect when you call blockCFun()? A or B?
Sorry, for the late response
...but clearly: B
> Answer: It depends on the order of declaring your scripts in
> <map:flow/>. The first helper() method declared will be found.
But there is only one helper() method per block!?
cheers
--
Torsten
Re: Blocks, Flow and Dependencies [was RE: Splitting xconf files
step 2: the sitemap]
Posted by Reinhard Poetz <re...@apache.org>.
Glen Ezkovich wrote:
>
> On Jan 10, 2005, at 9:07 AM, Torsten Curdt wrote:
>
>>>>> So it seems, flow replaces components? If createNewAccount()
>>>>> gathers sends pages, collects information, creates an Account, etc.
>>>>> then why not just use cocoon.sendPageAndWait?
>>>>
>>>>
>>>>
>>>> because this is done in the called block, not by the callee.
>>>
>>> Yes, and when sendPageAndWait returns the calling blocks flow
>>> continues with a new account accessible from the session. Maybe we
>>> need a new method such as callFunction.
>>
>>
>> sorry, guys ...you've lost me here.
>> I don't get the problem.
>
>
> Neither do I. :-/
Problem:
flow.js of blockA
------------------
function blockAFunc() {
return helper();
}
function helper() {
return "A";
}
flow.js of blockB
-----------------
function blockBFunc() {
return helper();
}
function helper() {
return "B";
}
flow.js of blockC
-----------------
function blockCFunc() {
print(blockB());
}
What do you expect when you call blockCFun()? A or B?
Answer: It depends on the order of declaring your scripts in <map:flow/>. The
first helper() method declared will be found.
That's one of the reasons for all this noise. Otherwise I would be agree with
you that we don't need isolation at this level.
--
Reinhard
Re: Blocks, Flow and Dependencies [was RE: Splitting xconf files step 2: the sitemap]
Posted by Glen Ezkovich <gl...@hard-bop.com>.
On Jan 10, 2005, at 9:07 AM, Torsten Curdt wrote:
>>>> So it seems, flow replaces components? If createNewAccount()
>>>> gathers sends pages, collects information, creates an Account, etc.
>>>> then why not just use cocoon.sendPageAndWait?
>>>
>>>
>>> because this is done in the called block, not by the callee.
>> Yes, and when sendPageAndWait returns the calling blocks flow
>> continues with a new account accessible from the session. Maybe we
>> need a new method such as callFunction.
>
> sorry, guys ...you've lost me here.
> I don't get the problem.
Neither do I. :-/
>
> Btw: while working on the javaflow
> stuff I felt a very strong urge to
> refactor the sitemap-flow interface.
>
> (see the JavaInterpreter in the
> javaflow block. I've put a revisit
> into the callFunction method)
>
> cheers
> --
> Torsten
>
>
>
Glen Ezkovich
HardBop Consulting
glen at hard-bop.com
http://www.hard-bop.com
A Proverb for Paranoids:
"If they can get you asking the wrong questions, they don't have to
worry about answers."
- Thomas Pynchon Gravity's Rainbow
Re: Blocks, Flow and Dependencies [was RE: Splitting xconf files
step 2: the sitemap]
Posted by Torsten Curdt <tc...@apache.org>.
>>> So it seems, flow replaces components? If createNewAccount() gathers
>>> sends pages, collects information, creates an Account, etc. then why
>>> not just use cocoon.sendPageAndWait?
>>
>>
>> because this is done in the called block, not by the callee.
>
>
> Yes, and when sendPageAndWait returns the calling blocks flow continues
> with a new account accessible from the session. Maybe we need a new
> method such as callFunction.
sorry, guys ...you've lost me here.
I don't get the problem.
Btw: while working on the javaflow
stuff I felt a very strong urge to
refactor the sitemap-flow interface.
(see the JavaInterpreter in the
javaflow block. I've put a revisit
into the callFunction method)
cheers
--
Torsten
Re: Blocks, Flow and Dependencies [was RE: Splitting xconf files step 2: the sitemap]
Posted by Glen Ezkovich <gl...@hard-bop.com>.
On Jan 10, 2005, at 7:24 AM, Reinhard Poetz wrote:
>> So it seems, flow replaces components? If createNewAccount() gathers
>> sends pages, collects information, creates an Account, etc. then why
>> not just use cocoon.sendPageAndWait?
>
> because this is done in the called block, not by the callee.
Yes, and when sendPageAndWait returns the calling blocks flow continues
with a new account accessible from the session. Maybe we need a new
method such as callFunction.
<snip/>
>> Seems like you want a round peg in a square hole. Just invoke the
>> function by loading its file and this problem goes away.
>>>
>>>
>>> If Javascript supported namespaces, I would agree with you.
>>>
Then the thing to do might be to designate certain javascript files as
public and others as private in the block's configuration file.
Glen Ezkovich
HardBop Consulting
glen at hard-bop.com
http://www.hard-bop.com
A Proverb for Paranoids:
"If they can get you asking the wrong questions, they don't have to
worry about answers."
- Thomas Pynchon Gravity's Rainbow
Re: Blocks, Flow and Dependencies [was RE: Splitting xconf files
step 2: the sitemap]
Posted by Reinhard Poetz <re...@apache.org>.
Glen Ezkovich wrote:
>
> On Jan 10, 2005, at 3:50 AM, Daniel Fagerstrom wrote:
>
>> Reinhard Poetz wrote:
>> <snip/>
>>
>>> I think of composing an application out of flow calls:
>>>
>>> function myF() {
>>>
>>> var newAccount = [here call a flow function of another block]
>>> e.g. cocoon.blocks.blockB.createNewAccount();
>>> if(newAccount.type == "xyz") {
>>> cocoon.sendPage("xyz");
>>> }
>>> else {
>>> cocoon.sendPage("abc");
>>> }
>>> }
>>>
>
> So it seems, flow replaces components? If createNewAccount() gathers
> sends pages, collects information, creates an Account, etc. then why not
> just use cocoon.sendPageAndWait?
because this is done in the called block, not by the callee.
>>> So calling another block has to return a Java(script) object (a
>>> stream of SAX
>>> events doesn't help here!)
>
>
> Of course. Thats why you should be using be invoking a method on a Java
> object. If you do not know how to use a Java object from flow you
> shouldn't be writing flowscripts. Once you have written a flowscript in
> your Account block you should be able to use that flow script from any
> block directly. Its just a script.
>
>>> and I don't want to care which flowscript files have
>>> to be loaded to make my call work.
>
>
> Then load(block://account/flowscript.js); or something similar.
>
>>>
>>> If we go this way we have to solve the problem that the flowscript of
>>> the other
>>> block runs completly isoluated from the calling the block.
>>
>>
>> I think that is the way to go.
>>
>> The important thing IMO is that when we use a flowscript today, it has
>> access to a global context in terms of the cocoon object. When we
>> introduce blocks each block must have a own cocoon object.
>
>
> hmm...
>
>> This block local cocoon object has access to global stuff as before
>> but also to such things that are internal to the block. Also all
>> relative URIs must be resolved by relative the block rather than
>> relative the user. There might be internal pipelines that the block
>> resolver has access to but that not are exported.
>
>
> Thats why a block manager is needed, not individual local cocoon objects.
>
>>
>> This means that we cannot consider the exported flow calls as normal
>> java script functions anymore, they are more like methods that are
>> invoked at a certain object. And the syntax:
>
>
> I still don't see this. Then you should be creating objects and invoking
> methods on them.
>
>>
>> cocoon.blocks.blockB.createNewAccount();
>>
>> illustrates that interpretation in a nice way.
>
>
> This just seems like a very complex way to implement the invocation of a
> function in flow.
>
>>
>> A question here is what flowscript functions that should be exported
>> from a block. I would prefer to explictly enumerate the functions and
>> possibly whole scripts that are exported rather than exporting
>> everything in the map:flow sections.
>
>
> I guess this makes sense but if you use java flow you have method access
> modifiers to handle this.
>
>>
>>> This has the
>>> advantage that we don't have to work around the missing namespace
>>> concept of
>>> Javascript but has the disadvantage that we have to find a way that
>>> in the other
>>> block (runs isolated from the first block) continuations are created
>>> and that we
>>> have to return the result of this function to the calling block.
>>>
>>> I fear that this isn't possible ...
>>
>>
>> Can you expand on why you fear that it is impossible. Concerning web
>> continuations I would assume that the normal case is that they are
>> local to the block that creates them and handled by rules in the
>> blocks sitemap, and that links are handled with the block link
>> rewriting mechanism. Then it is the block writers choice to put the
>> continuation handling sitemap rule in the external or the internal
>> pipeline.
>
>
> Seems like you want a round peg in a square hole. Just invoke the
> function by loading its file and this problem goes away.
If Javascript supported namespaces, I would agree with you.
--
Reinhard
Re: Blocks, Flow and Dependencies [was RE: Splitting xconf files step 2: the sitemap]
Posted by Glen Ezkovich <gl...@hard-bop.com>.
On Jan 10, 2005, at 3:50 AM, Daniel Fagerstrom wrote:
> Reinhard Poetz wrote:
> <snip/>
>
>> I think of composing an application out of flow calls:
>>
>> function myF() {
>>
>> var newAccount = [here call a flow function of another block]
>> e.g. cocoon.blocks.blockB.createNewAccount();
>> if(newAccount.type == "xyz") {
>> cocoon.sendPage("xyz");
>> }
>> else {
>> cocoon.sendPage("abc");
>> }
>> }
>>
So it seems, flow replaces components? If createNewAccount() gathers
sends pages, collects information, creates an Account, etc. then why
not just use cocoon.sendPageAndWait?
>>
>> So calling another block has to return a Java(script) object (a
>> stream of SAX
>> events doesn't help here!)
Of course. Thats why you should be using be invoking a method on a Java
object. If you do not know how to use a Java object from flow you
shouldn't be writing flowscripts. Once you have written a flowscript in
your Account block you should be able to use that flow script from any
block directly. Its just a script.
>> and I don't want to care which flowscript files have
>> to be loaded to make my call work.
Then load(block://account/flowscript.js); or something similar.
>>
>> If we go this way we have to solve the problem that the flowscript of
>> the other
>> block runs completly isoluated from the calling the block.
>
> I think that is the way to go.
>
> The important thing IMO is that when we use a flowscript today, it has
> access to a global context in terms of the cocoon object. When we
> introduce blocks each block must have a own cocoon object.
hmm...
> This block local cocoon object has access to global stuff as before
> but also to such things that are internal to the block. Also all
> relative URIs must be resolved by relative the block rather than
> relative the user. There might be internal pipelines that the block
> resolver has access to but that not are exported.
Thats why a block manager is needed, not individual local cocoon
objects.
>
> This means that we cannot consider the exported flow calls as normal
> java script functions anymore, they are more like methods that are
> invoked at a certain object. And the syntax:
I still don't see this. Then you should be creating objects and
invoking methods on them.
>
> cocoon.blocks.blockB.createNewAccount();
>
> illustrates that interpretation in a nice way.
This just seems like a very complex way to implement the invocation of
a function in flow.
>
> A question here is what flowscript functions that should be exported
> from a block. I would prefer to explictly enumerate the functions and
> possibly whole scripts that are exported rather than exporting
> everything in the map:flow sections.
I guess this makes sense but if you use java flow you have method
access modifiers to handle this.
>
>> This has the
>> advantage that we don't have to work around the missing namespace
>> concept of
>> Javascript but has the disadvantage that we have to find a way that
>> in the other
>> block (runs isolated from the first block) continuations are created
>> and that we
>> have to return the result of this function to the calling block.
>>
>> I fear that this isn't possible ...
>
> Can you expand on why you fear that it is impossible. Concerning web
> continuations I would assume that the normal case is that they are
> local to the block that creates them and handled by rules in the
> blocks sitemap, and that links are handled with the block link
> rewriting mechanism. Then it is the block writers choice to put the
> continuation handling sitemap rule in the external or the internal
> pipeline.
Seems like you want a round peg in a square hole. Just invoke the
function by loading its file and this problem goes away.
>
> Concering objects that are returned from a block flowscript function I
> wouldn't don't see any problem (yet ;) ) it is an ordinary Java class,
> possibly from some Rhino name space.
Precisely. Flowscripts are not components. Neither are a collection of
flow functions. If you want to make them so then provide a component as
a wrapper. look it up as usual and then invoke its methods all from
within a single flowscript function.
I'm sure if someone implemented things as you both describe I would
take advantage of it. But I really think you could achieve the same
results in a simpler way.
Glen Ezkovich
HardBop Consulting
glen at hard-bop.com
http://www.hard-bop.com
A Proverb for Paranoids:
"If they can get you asking the wrong questions, they don't have to
worry about answers."
- Thomas Pynchon Gravity's Rainbow
Re: Blocks, Flow and Dependencies [was RE: Splitting xconf files
step 2: the sitemap]
Posted by Daniel Fagerstrom <da...@nada.kth.se>.
Reinhard Poetz wrote:
<snip/>
> I think of composing an application out of flow calls:
>
> function myF() {
>
> var newAccount = [here call a flow function of another block]
> e.g. cocoon.blocks.blockB.createNewAccount();
> if(newAccount.type == "xyz") {
> cocoon.sendPage("xyz");
> }
> else {
> cocoon.sendPage("abc");
> }
> }
>
>
> So calling another block has to return a Java(script) object (a stream
> of SAX
> events doesn't help here!) and I don't want to care which flowscript
> files have
> to be loaded to make my call work.
>
> If we go this way we have to solve the problem that the flowscript of
> the other
> block runs completly isoluated from the calling the block.
I think that is the way to go.
The important thing IMO is that when we use a flowscript today, it has
access to a global context in terms of the cocoon object. When we
introduce blocks each block must have a own cocoon object. This block
local cocoon object has access to global stuff as before but also to
such things that are internal to the block. Also all relative URIs must
be resolved by relative the block rather than relative the user. There
might be internal pipelines that the block resolver has access to but
that not are exported.
This means that we cannot consider the exported flow calls as normal
java script functions anymore, they are more like methods that are
invoked at a certain object. And the syntax:
cocoon.blocks.blockB.createNewAccount();
illustrates that interpretation in a nice way.
A question here is what flowscript functions that should be exported
from a block. I would prefer to explictly enumerate the functions and
possibly whole scripts that are exported rather than exporting
everything in the map:flow sections.
> This has the
> advantage that we don't have to work around the missing namespace
> concept of
> Javascript but has the disadvantage that we have to find a way that in
> the other
> block (runs isolated from the first block) continuations are created
> and that we
> have to return the result of this function to the calling block.
>
> I fear that this isn't possible ...
Can you expand on why you fear that it is impossible. Concerning web
continuations I would assume that the normal case is that they are local
to the block that creates them and handled by rules in the blocks
sitemap, and that links are handled with the block link rewriting
mechanism. Then it is the block writers choice to put the continuation
handling sitemap rule in the external or the internal pipeline.
Concering objects that are returned from a block flowscript function I
wouldn't don't see any problem (yet ;) ) it is an ordinary Java class,
possibly from some Rhino name space.
<snip/>
/Daniel
Re: Blocks, Flow and Dependencies [was RE: Splitting xconf files
step 2: the sitemap]
Posted by Reinhard Poetz <re...@apache.org>.
Glen Ezkovich wrote:
>
> On Jan 9, 2005, at 7:33 PM, Mark Lundquist wrote:
>
>>
>>> From: Glen Ezkovich [mailto:glen@hard-bop.com]
>>> On Jan 9, 2005, at 4:17 PM, Mark Lundquist wrote:
>>>
>>>> Do we really want inter-block flowscript function calls?
>>
>>
>> Actually, I guess we do... there are some blocks that are meant to be
>> used
>> from flow, for which passing requests and SAX streams isn't the best
>> model.
>> Think of an authentication module, for instance. Or, to use your
>> example,
>> Forms!
I think of composing an application out of flow calls:
function myF() {
var newAccount = [here call a flow function of another block]
e.g. cocoon.blocks.blockB.createNewAccount();
if(newAccount.type == "xyz") {
cocoon.sendPage("xyz");
}
else {
cocoon.sendPage("abc");
}
}
So calling another block has to return a Java(script) object (a stream of SAX
events doesn't help here!) and I don't want to care which flowscript files have
to be loaded to make my call work.
If we go this way we have to solve the problem that the flowscript of the other
block runs completly isoluated from the calling the block. This has the
advantage that we don't have to work around the missing namespace concept of
Javascript but has the disadvantage that we have to find a way that in the other
block (runs isolated from the first block) continuations are created and that we
have to return the result of this function to the calling block.
I fear that this isn't possible ...
If I'm right that we can't find a way to make this "isolated flowscript call"
work, we can still think of including other blocks flowscripts the usual way in
the <map:flow>-sections. But it looks more like a hack.
> Of course. But you want to use a service not invoke a javascript
> function. What you would want is to get the service, make a request and
> get the result. Not knowing what the intricacies of the block system
> will be, I would imagine something along the lines of
>
> var authService =
> cocoon.get("block://authentication/authenticationService");
> var isAuthorized = authService.authorize(user, pwd);
>
> would make more sense. Or more likely this still might be done by the
> current service lookup methods but the service will be provided by the
> authentication block. (Though I do like the simplicity of the above.) If
> you implemented you app's authentication in javascript and deployed it
> as a block you could just use it from flow like
>
> cocoon.sendPageAndWait("block://authentication/authenticate",
> "block://currentBlock/loginPage");
>
> Where all you are essentially doing is redirecting to the authentication
> blocks sitemap. It really just depends on what exactly it is you want
> the block to do.
>
> The way I understand it, one of the main points of blocks is to make it
> easier to configure Cocoon with just the components you need for your
> application. Once the various components are wired together we shouldn't
> really need to do anything differently. If a block has a dependency on
> another block it should be able to use the existing methods to realize
> that dependency. All of the magic should be done by Cocoon and the Block
> Manager.
>
>> So, I withdraw my question... but I guess I would like to see what block
>> contracts would look like at the flow level!
>
>
> Can you explain what a contract between blocks is? I'm lost here. I
> thought a contract was between the client and the
> method/function/pipeline it invokes. The client agrees to meet certain
> requirements of the method/function/pipeline before invoking it and the
> method/function/pipeline then agrees to perform certain tasks and/or
> return correct and valid results.
>
>> Perhaps a flowscript object
>> that encapsulates the flowscript API for the block?
>> Actually, a Java interface could express that...
>
>
> Seems like overkill.
see above
--
Reinhard