Re: Process one PloneFormGen request into many SQL tables

"Charlie Clark" <[email protected]>
Newsgroups gmane.comp.web.zope.database
Organization eGenix.com
Message-ID <[email protected]>
Am 19.01.2007, 14:30 Uhr, schrieb Paul Eipper <[email protected]>:

> I have a Form (generated with PloneFormGen+DataGridField) and I need
> to send the data entered there into several mySQL tables. I am
> guessing a Python script would be the right thing here.(?)

Can't tell you much about what the Plone thing wants but a PythonScript is  
probably indeed what you want.

>  My main questions right now are:
>  1) How do I maintain referencial integrity?
> I need to get LAST_INSERT_ID() from the first INSERT to use on the
> following inserts.
> Could I have a ZSQL Method that does the insert and returns the
> generated ID to the Python script?

Yes, or you could call do this call directly in SQL or possibly even in  
the default for a particularl relational variable.

>  2) Is a ZSQL Method automatically executed as a transaction? Or do I
> need to manually define BEGIN; COMMIT; to guarantee I am getting the
> correct data?

Yes.

>  3) Where can I find example code (zsql, python scripts) dealing with
> many related tables? All tutorials I found deal with only one table at
> a time, completely ignoring the relational part of the database.

Well, to be honest they only show you how to use SQL from within Zope  
which is essentially write the SQL yourself and let Zope help you manage  
your variables.

Charlie
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.