Re: How do I use my archetypes-generated form to insert data into a mysql table?

"Charlie Clark" <[email protected]>
Newsgroups gmane.comp.web.zope.database
Organization eGenix.com
Message-ID <[email protected]>
Am 16.10.2006, 14:13 Uhr, schrieb Anna Falkowska <[email protected]>:

> I made a form using ArchGenXML and want to use it to populate a table
> in a mysql database. So far I have not come across a good tutorial on
> how to do this. Someone suggested I use ZSQL methods. I understand how
> to create them, but how exactly would I call a ZSQL method with the
> information from my form?

Hi,

check the section on ZSQL in the Zope Book to understand how ZSQL works  
but I suggest you proceed as follows.
Pass your form into a PythonScript to run checks pretty much like this:

request = context.REQUEST

for item in request.form.keys():
	validate(item)

if no_errors:
	context.SQL.someZSQLMethod(dictionary_of_items)
	return context.thank_you_page()

else:
	return context.error_page()

Charlie
-- 
Charlie Clark
eGenix.com

Professional Python Services directly from the Source
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
Try mxODBC.Zope.DA for Windows, Mac OS, Linux, Solaris, FreeBSD for free!
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.