You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Litrik De Roy <co...@litrik.com> on 2003/10/15 21:23:13 UTC

Redirect following a transformer does not execute the transformer

Imagine the following pipeline:

  <map:match pattern="delete">
    <map:generate src="delete.xml"/>
    <map:transform type="write-source"/>
    <map:redirect-to uri="list"/>
  </map:match>

I have noticed that the Source Writing transformer does not get executed ?
It looks like the sitemap is "optimizing" the pipeline and assuming "hey,
I'll need to redirect, why bother doing the generate and transform".

Does this work as designed, or am I missing something?

PS: The use case for the above pipeline is displaying a list where the user
can delete some entry. This calls the "delete" url (typically with some
parameters) but I want to prevent that the browser shows the delete url in
the address bar. So I redirect to the list URL which refreshes the list and
displays a very nice URL (but unfortunately no longer executes the
transform).

Litrik De Roy
www.litrik.com



Re: Redirect following a transformer does not execute the transformer

Posted by Litrik De Roy <co...@litrik.com>.
----- Original Message ----- 
From: "Tony Collen" <co...@umn.edu>

> Litrik De Roy wrote:
> > Imagine the following pipeline:
> >
> >   <map:match pattern="delete">
> >     <map:generate src="delete.xml"/>
> >     <map:transform type="write-source"/>
> >     <map:redirect-to uri="list"/>
> >   </map:match>
> >
> > I have noticed that the Source Writing transformer does not get executed
?
> > It looks like the sitemap is "optimizing" the pipeline and assuming
"hey,
> > I'll need to redirect, why bother doing the generate and transform".
> >
> > Does this work as designed, or am I missing something?
>
> Hmm, I'm not 100% on the inner functionality of Cocoon's pipelines, but it
could be the way they are
> assembled before any data is sent through.

Neither do I know the internals of the pipeline. And I can't seem to find
the source of the code doing the sitemap stuff. I can locate and understand
the source of a simple generator, but the sitemap itself...

>
> > PS: The use case for the above pipeline is displaying a list where the
user
> > can delete some entry. This calls the "delete" url (typically with some
> > parameters) but I want to prevent that the browser shows the delete url
in
> > the address bar. So I redirect to the list URL which refreshes the list
and
> > displays a very nice URL (but unfortunately no longer executes the
> > transform).
>
>
> If you're trying to delete a file, perhaps an action would be more
appropriate?
>

Well I'm doing a lot of different things: aggregate some data, send it
through a custom transformer, do some extra xsl, send it through the session
transformer to update some xml stored in my session context, next send it
through the source writing transformer to update a snippet of xml on disk.

The pipeline works beautifully without the redirect. But to get rid of the
ugly URL in the browser I was hoping to use a redirect.

> Regards,

Thanks for your feedback.

>
> Tony
>

Litrik De Roy
www.litrik.com



Re: Redirect following a transformer does not execute the transformer

Posted by Vadim Gritsenko <va...@verizon.net>.
Litrik De Roy wrote:

>From: "Carsten Ziegeler" <cz...@s-und-n.de>
>  
>
...

>>A cocoon pipeline is execute after the serializer is set, so
>>as long as you dont have a serializer, the pipeline does simply
>>nothing.
>>A redirect is executed immediately and then the processing stops.
>>    
>>
>
>I think I'll have to read this a couple of times before I really understand
>all the implications of this.
>
>At first sight this seems to be a serious limitation.... but again... I
>migth not grasp it (yet).
>
>  
>
>>So, in your case a pipeline with a generator and a transformer
>>is setup, but not executed; the redirect is reached and
>>executed.
>>So, using an action seems a better way. You can e.g. call
>>a pipeline from within the action and then making
>>your redirect
>>    
>>
>
>So I get:
>- Generator
>  
>

Strike generator from here...


>- Action
>- Redirect
>
>And the action will get executed even though there is no serializer? I think
>I'm getting confused....
>  
>

Litrik,

You are seriously missing something (and you were suspecting this 
already, so it won't be news to you ;-).

All sitemap components are divided onto two groups: direct components 
and indirect components. All sitemap processing happens in two stages. 
In the first stage, indirect components define what components pipeline 
will consist of, and instance of the pipeline is assembled. During the 
second stage, this pipeline instance is executed. Once you understand 
this simple fact, there will be no confusion.


Some reference material:

If you want to understand how sitemap works, read more in this thread:
    http://marc.theaimsgroup.com/?t=101053465300001&r=1&w=2
Shortcut to the list of direct and indirect components:
    http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=101057440717758&w=2
Shortcut to the "lint" sitemap:
    
http://cvs.apache.org/viewcvs/cocoon-2.0/src/webapp/mount/lint/sitemap.xmap?rev=1.1&content-type=text/vnd.viewcvs-markup


Vadim



Re: Redirect following a transformer does not execute the transformer

Posted by Litrik De Roy <co...@litrik.com>.
----- Original Message ----- 
From: "Carsten Ziegeler" <cz...@s-und-n.de>
To: <de...@cocoon.apache.org>
Sent: Wednesday, October 15, 2003 9:49 PM
Subject: RE: Redirect following a transformer does not execute the
transformer


> Tony Collen wrote:
> >
> > Litrik De Roy wrote:
> > > Imagine the following pipeline:
> > >
> > >   <map:match pattern="delete">
> > >     <map:generate src="delete.xml"/>
> > >     <map:transform type="write-source"/>
> > >     <map:redirect-to uri="list"/>
> > >   </map:match>
> > >
> > > I have noticed that the Source Writing transformer does not get
> > executed ?
> > > It looks like the sitemap is "optimizing" the pipeline and
> > assuming "hey,
> > > I'll need to redirect, why bother doing the generate and transform".
> > >
> > > Does this work as designed, or am I missing something?
> >
> > Hmm, I'm not 100% on the inner functionality of Cocoon's
> > pipelines, but it could be the way they are
> > assembled before any data is sent through.
> >
> A cocoon pipeline is execute after the serializer is set, so
> as long as you dont have a serializer, the pipeline does simply
> nothing.
> A redirect is executed immediately and then the processing stops.

I think I'll have to read this a couple of times before I really understand
all the implications of this.

At first sight this seems to be a serious limitation.... but again... I
migth not grasp it (yet).

> So, in your case a pipeline with a generator and a transformer
> is setup, but not executed; the redirect is reached and
> executed.
> So, using an action seems a better way. You can e.g. call
> a pipeline from within the action and then making
> your redirect

So I get:
- Generator
- Action
- Redirect

And the action will get executed even though there is no serializer? I think
I'm getting confused....

And "I can call a pipeline from within an action.", but this means that I'm
kind of obfuscating the way a URL is processed. The sitemap.xmap will no
longer be the only place to find out how something is processed, I'll have
to look at the source of the action as well.

>
> Carsten
>

Litrik De Roy
www.litrik.com


RE: Redirect following a transformer does not execute the transformer

Posted by Carsten Ziegeler <cz...@s-und-n.de>.
Tony Collen wrote:
> 
> Litrik De Roy wrote:
> > Imagine the following pipeline:
> > 
> >   <map:match pattern="delete">
> >     <map:generate src="delete.xml"/>
> >     <map:transform type="write-source"/>
> >     <map:redirect-to uri="list"/>
> >   </map:match>
> > 
> > I have noticed that the Source Writing transformer does not get 
> executed ?
> > It looks like the sitemap is "optimizing" the pipeline and 
> assuming "hey,
> > I'll need to redirect, why bother doing the generate and transform".
> > 
> > Does this work as designed, or am I missing something?
> 
> Hmm, I'm not 100% on the inner functionality of Cocoon's 
> pipelines, but it could be the way they are 
> assembled before any data is sent through.
> 
A cocoon pipeline is execute after the serializer is set, so
as long as you dont have a serializer, the pipeline does simply
nothing.
A redirect is executed immediately and then the processing stops.
So, in your case a pipeline with a generator and a transformer
is setup, but not executed; the redirect is reached and
executed.
So, using an action seems a better way. You can e.g. call
a pipeline from within the action and then making
your redirect

Carsten

Re: Redirect following a transformer does not execute the transformer

Posted by Tony Collen <co...@umn.edu>.
Litrik De Roy wrote:
> Imagine the following pipeline:
> 
>   <map:match pattern="delete">
>     <map:generate src="delete.xml"/>
>     <map:transform type="write-source"/>
>     <map:redirect-to uri="list"/>
>   </map:match>
> 
> I have noticed that the Source Writing transformer does not get executed ?
> It looks like the sitemap is "optimizing" the pipeline and assuming "hey,
> I'll need to redirect, why bother doing the generate and transform".
> 
> Does this work as designed, or am I missing something?

Hmm, I'm not 100% on the inner functionality of Cocoon's pipelines, but it could be the way they are 
assembled before any data is sent through.

> PS: The use case for the above pipeline is displaying a list where the user
> can delete some entry. This calls the "delete" url (typically with some
> parameters) but I want to prevent that the browser shows the delete url in
> the address bar. So I redirect to the list URL which refreshes the list and
> displays a very nice URL (but unfortunately no longer executes the
> transform).


If you're trying to delete a file, perhaps an action would be more appropriate?

Regards,

Tony

> 
> Litrik De Roy
> www.litrik.com
> 
>