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

2005-01-29 Thread Irv Salisbury III
As for the first solution, I am not necessarily saying it is the best 
approach, but you can still use your page:

map:match pattern=internal-logging/**
   database stuff in here
/map:match
map:match pattern=somepage
   map:aggregate element=aggregate
map:part src=cocoon:/internal-logging/somepage/
map:part src=mypage.xml/
   /map:aggregate
   rest of pipeline
/map:match
This allows you to call multiple generators and aggregate them 
together.  The limitation is that you can only aggregate the URL based 
generators.  You can't aggregate with other types of ones.  If your 
application always uses a file based generator, this will work fine for you.

As for the second solution, putting tags in your XML is a great idea.  I 
use that very often.  I would do it with a custom transformer that looks 
for those tags, but either way will work. (You will have more control in 
a custom transformer as it is pure java and you can do all the nice JDBC 
things, exception handling, etc)

Your other solution is to use flowscript (which I didn't mention before)
function main(){
   myDatabaseHelper.callDatabase();
   sendPage( whatever page );
}
Good luck.
Irv
David Swearingen wrote:
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:[EMAIL PROTECTED] 
Sent: Friday, January 28, 2005 11:15 AM
To: users@cocoon.apache.org; [EMAIL PROTECTED]
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
   

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Executing a database call for several different matches

2005-01-28 Thread David Swearingen
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



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

2005-01-28 Thread Irv Salisbury III
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


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

2005-01-28 Thread David Swearingen
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:[EMAIL PROTECTED] 
Sent: Friday, January 28, 2005 11:15 AM
To: users@cocoon.apache.org; [EMAIL PROTECTED]
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
  



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]