You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Irv Salisbury III <ir...@dotech.com> on 2005/01/28 17:15:15 UTC

Re: [Cocoon-Users] Executing a database call for several different matches

I don't know as I would do a redirect with all of them.  There are a 
number of different ways I could potentially attack this.  First, you 
could call a common starting internal pipeline:

<map:match pattern="internal-logging/**">
    <database stuff in here>
</map:match>

<map:match pattern="somepage">
    <map:generate src="cocoon:/internal-logging/somepage"/>
    <rest of pipeline>
</map:match>

I realize this takes up the precious generator spot in your pipeline, 
but is a possible solution I have used where I want all my pipelines to 
do something common.  You still could use an aggregator if you wanted.

Another possibility is to use a transformer or an action and then reuse 
that in various pipelines.

<map:match pattern="somepage">
    <map:action type="mydatabase">
       <map:param name="page" value="somepage"/>
       <now do rest of pipeline>
    </map:action>
</map:match>

<map:match pattern="somepage">
    <map:generate src="whatever"/>
     <map:transform type="mydatabase"/>
    <rest of pipeline>
</map:match>

They both have pros and cons.  With the transformer, you could do 
special tags that represent what you want logged and then just make sure 
they are in your XML pipeline going through the system. This is usually 
have I write something like that.  In fact, if you piggybacked it on the 
SQLTransformer, then the mydatabase transformer could just be an XSL 
that sets up the SQL calls.

Hopefully this helps somewhat.

Irv

David Swearingen wrote:

>I'm building a little logging system that will create a record in a database
>anytime one of about 20 different pages on my site is hit.  So there are now
>say 20 different map:matches for these pages.  I don't want to insert some
>kind of database call (ESQL, Action, other) in each map:match pattern since
>that isn't very elegant nor maintainable.  So I need suggestions on good
>Cocoon patterns or best practices that allow "something" to happen for a
>specific set of map:match's.
>
>I'm thinking maybe if I slightly modify my existing 20 patterns to always
>start the same, e.g. in this case with the 'mypages' path:
>
><map:match pattern="mypages/somepath/about_this_site.html>
><map:match pattern="mypages/somepath/management.html>
><map:match pattern="mypages/somepath/services.html>
>
>then I could create an additional new match like this, that every request
>would go through first:
>
><map:match pattern=mypages/**/*.html>
>	do the database call
>	<map:redirect-to uri="mypages/{1}/{2}.html"/>
></map:match>
>
>And then the redirect would send the request on to the next proper match.  
>
>Will this work?  Is this the best way?
>
>Thanks,
>David
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>For additional commands, e-mail: users-help@cocoon.apache.org
>  
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


RE: [Cocoon-Users] Executing a database call for several different matches

Posted by David Swearingen <sw...@yahoo.com>.
Thanks Irv.  With respect to your first solution, I'm not sure I understand
how I can still conduct my logic if the generator spot gets taken by the
database call.  I need to think about that some more.  All my patterns start
with a page template in the generator.

As for the second solution, it reminds me of one idea I was considering:
dropping a special element in my page template like <do_database_write/> and
when my final style sheet sees this, it calls a Xalan Java extension which
is simply raw Java JDBC hit.  If anyone thinks that's not a decent approach,
please advise.




-----Original Message-----
From: Irv Salisbury III [mailto:irv@dotech.com] 
Sent: Friday, January 28, 2005 11:15 AM
To: users@cocoon.apache.org; swearingendw@yahoo.com
Subject: Re: [Cocoon-Users] Executing a database call for several different
matches

I don't know as I would do a redirect with all of them.  There are a number
of different ways I could potentially attack this.  First, you could call a
common starting internal pipeline:

<map:match pattern="internal-logging/**">
    <database stuff in here>
</map:match>

<map:match pattern="somepage">
    <map:generate src="cocoon:/internal-logging/somepage"/>
    <rest of pipeline>
</map:match>

I realize this takes up the precious generator spot in your pipeline, but is
a possible solution I have used where I want all my pipelines to do
something common.  You still could use an aggregator if you wanted.

Another possibility is to use a transformer or an action and then reuse that
in various pipelines.

<map:match pattern="somepage">
    <map:action type="mydatabase">
       <map:param name="page" value="somepage"/>
       <now do rest of pipeline>
    </map:action>
</map:match>

<map:match pattern="somepage">
    <map:generate src="whatever"/>
     <map:transform type="mydatabase"/>
    <rest of pipeline>
</map:match>

They both have pros and cons.  With the transformer, you could do special
tags that represent what you want logged and then just make sure they are in
your XML pipeline going through the system. This is usually have I write
something like that.  In fact, if you piggybacked it on the SQLTransformer,
then the mydatabase transformer could just be an XSL that sets up the SQL
calls.

Hopefully this helps somewhat.

Irv

David Swearingen wrote:

>I'm building a little logging system that will create a record in a 
>database anytime one of about 20 different pages on my site is hit.  So 
>there are now say 20 different map:matches for these pages.  I don't 
>want to insert some kind of database call (ESQL, Action, other) in each 
>map:match pattern since that isn't very elegant nor maintainable.  So I 
>need suggestions on good Cocoon patterns or best practices that allow 
>"something" to happen for a specific set of map:match's.
>
>I'm thinking maybe if I slightly modify my existing 20 patterns to 
>always start the same, e.g. in this case with the 'mypages' path:
>
><map:match pattern="mypages/somepath/about_this_site.html>
><map:match pattern="mypages/somepath/management.html>
><map:match pattern="mypages/somepath/services.html>
>
>then I could create an additional new match like this, that every 
>request would go through first:
>
><map:match pattern=mypages/**/*.html>
>	do the database call
>	<map:redirect-to uri="mypages/{1}/{2}.html"/> </map:match>
>
>And then the redirect would send the request on to the next proper match.  
>
>Will this work?  Is this the best way?
>
>Thanks,
>David
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>For additional commands, e-mail: users-help@cocoon.apache.org
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org