You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Antonio Gallardo <ag...@agsoftware.dnsalias.com> on 2003/05/21 03:31:07 UTC
Actions and Modular Databases Actions
Hi:
I have the following scenario:
I need to generate some data based on a request from the user. The problem
is that this data will use more than 1 table. Then we need to use Database
transactions. We also know that Modular Database Actions are
transactional. They can do the work.
After thinking about the solution of this problem, we tought that in order
to prepare the data before the use of "DatabaseAddAction". We need to
build an Action. Here is a scratch of the sitemap:
1- <map:match pattern="resultpage">
2- <map:action type="preparedata">
3- <map:action type="mod-db-add">
4- <map:parameter name="table-set" value="my_table_set"/>
5- <map:generate ......>
6- </map:action>
7- <!-- error cannot insert into database -->
8- </map:action>
9- <!-- error, cannot prepare data -->
10 </map:match>
The question is:
If we will store the data into line 2, the action will return new data
into a "map" (As normal). But I dont know how to tell that the parameters
will come from returned map and not from the traditional:
request-param.
When the client send the parameters trought a request we write into
database.xml:
<table name="auth_users">
<keys>
<key name="usr_id" type="long" autoincrement="true">
<mode name="auto" type="autoincr"/>
<mode name="request-param" parameter="usr_id" type="others"/>
</key>
</keys>
<values>
<value name="usr_login" type="string">
<mode name="request-param" parameter="usr_login" type="all"/>
</value>
<value name="usr_fullname" type="string">
<mode name="request-param" parameter="usr_fullname" type="all"/>
</value>
</values>
</table>
How to configure the descriptor file "database.xml". In order to get the
parameters from a map returned from an Action.
****************************************
P.S: We also thinked we can write a normal request inside the action an do
a redirection with the parameter string included, something like:
http://localhost:8080/resultpage?mypar1=1&mypar2=2&mypar3=3&mypar1=4
But I dont like this solution since I think it is posible to dont do the
redirection.
*****************************************
Please we need an advise.
Best Regards,
Antonio Gallardo.
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org
[SUMMARY] Actions and Modular Databases Actions
Posted by Antonio Gallardo <ag...@agsoftware.dnsalias.com>.
Hi Chris:
Thanks for your advise, it help us to decide the way we solved this. With
two pipelines, one public and one internal.
<!-- Public pipeline -->
<!-- Call a Custom Action to generate data before insert-->
1- <map:match type="request-parameter" pattern="cocoon-action-Generate">
2- <map:act type="xsp-action" src="prepare-data.xsp">
3- <map:parameter name="param1" value="{request-param:param1}"/>
4- <map:parameter name="param2" value="{request-param:param2}"/>
5- <map:parameter name="param3" value="{request-param:param3}"/>
6- <map:parameter name="param4" value="{request-param:param4}"/>
7- <map:redirect-to uri="cocoon:raw://{insert_pipeline}"/>
8- </map:act>
9- </map:match>
The Action (line 2) query data from the databse and returns the URI
"insert_pipeline" that is called at line 7. "insert_pipeline" looks like:
executeinsert?param1=1¶m2=2¶m3=3 ......
Of course into the internal pipeline that process the line 7 there is a
traditional modular database insert action.
I dont know if this is the best practices or a elegant solution that but
this works. But I think is secure. The prepared data in line 2 are
inserted in 3 tables where is a cascade master-details, master-detail.
By the way we dont liked the idea to make another database_pool with
<autocommit>false</autocommit> and control all the BEGIN TRANSACTION,
COMMIT and ROLLBACK into the Action. I think this will be a very ugly
solution.
I attached a diagram that describes what we did.
Well thanks for your advise again.
Beest Regards,
Antonio Gallardo.
Christian Haul dijo:
> On 20.May.2003 -- 07:31 PM, Antonio Gallardo wrote:
>> Hi:
>>
>> I have the following scenario:
>>
>> I need to generate some data based on a request from the user. The
>> problem is that this data will use more than 1 table. Then we need to
>> use Database transactions. We also know that Modular Database Actions
>> are
>> transactional. They can do the work.
>>
>> After thinking about the solution of this problem, we tought that in
>> order to prepare the data before the use of "DatabaseAddAction". We
>> need to build an Action. Here is a scratch of the sitemap:
>>
>> 1- <map:match pattern="resultpage">
>> 2- <map:action type="preparedata">
>> 3- <map:action type="mod-db-add">
>> 4- <map:parameter name="table-set" value="my_table_set"/>
>> 5- <map:generate ......>
>> 6- </map:action>
>> 7- <!-- error cannot insert into database -->
>> 8- </map:action>
>> 9- <!-- error, cannot prepare data -->
>> 10 </map:match>
>>
>> The question is:
>>
>> If we will store the data into line 2, the action will return new data
>> into a "map" (As normal). But I dont know how to tell that the
>> parameters will come from returned map and not from the traditional:
>
> Indeed, there is currently no way for an input module to get at the
> sitemap variables. I fear it's not easily hackable because
> aggregations and includes share the same request IIRC.
>
> So you need to store your data that is accessible from a
> module. Request attributes come to mind for this.
>
> Another idea could be to prepare the data in a module. Of course this
> depends on the complexity of the preparation and the dependencies
> among the values.
>
> Chris.
> --
> C h r i s t i a n H a u l
> haul@informatik.tu-darmstadt.de
> fingerprint: 99B0 1D9D 7919 644A 4837 7D73 FEF9 6856 335A 9E08
>
> --------------------------------------------------------------------- To
> unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
Re: Actions and Modular Databases Actions
Posted by Christian Haul <ha...@dvs1.informatik.tu-darmstadt.de>.
On 20.May.2003 -- 07:31 PM, Antonio Gallardo wrote:
> Hi:
>
> I have the following scenario:
>
> I need to generate some data based on a request from the user. The problem
> is that this data will use more than 1 table. Then we need to use Database
> transactions. We also know that Modular Database Actions are
> transactional. They can do the work.
>
> After thinking about the solution of this problem, we tought that in order
> to prepare the data before the use of "DatabaseAddAction". We need to
> build an Action. Here is a scratch of the sitemap:
>
> 1- <map:match pattern="resultpage">
> 2- <map:action type="preparedata">
> 3- <map:action type="mod-db-add">
> 4- <map:parameter name="table-set" value="my_table_set"/>
> 5- <map:generate ......>
> 6- </map:action>
> 7- <!-- error cannot insert into database -->
> 8- </map:action>
> 9- <!-- error, cannot prepare data -->
> 10 </map:match>
>
> The question is:
>
> If we will store the data into line 2, the action will return new data
> into a "map" (As normal). But I dont know how to tell that the parameters
> will come from returned map and not from the traditional:
Indeed, there is currently no way for an input module to get at the
sitemap variables. I fear it's not easily hackable because
aggregations and includes share the same request IIRC.
So you need to store your data that is accessible from a
module. Request attributes come to mind for this.
Another idea could be to prepare the data in a module. Of course this
depends on the complexity of the preparation and the dependencies
among the values.
Chris.
--
C h r i s t i a n H a u l
haul@informatik.tu-darmstadt.de
fingerprint: 99B0 1D9D 7919 644A 4837 7D73 FEF9 6856 335A 9E08
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org