[Zope-DB] How do I use my archetypes-generated form to insert data into a mysql table?

Charlie Clark charlie at egenix.com
Mon Oct 16 09:23:04 EDT 2006


Am 16.10.2006, 14:13 Uhr, schrieb Anna Falkowska <afalkows at umich.edu>:

> 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!


More information about the Zope-DB mailing list