[Zope-DB] updating fields in a zsql method programmatically
Charlie Clark
charlie at egenix.com
Mon Aug 27 15:59:47 EDT 2007
Am 27.08.2007, 15:59 Uhr, schrieb onsombal <onsombal at yahoo.com>:
> changed_field1 = form.get('field1')
> changed_field1 = "a new computed value"
> field1 = changed_field1
> #create a new record with form field results for field2 & field3, and a
> computed value for field1
> context.insertNew()
^^^^^^^^^^^^^^^^^^^^^
This is really bad as it undoes all your good work of checking the the
values in your script. All ZSQL methods also have access to the REQUEST
object by default so your ZSQL method sees context.REQUEST.field1. Way
back when ZSQL was developed support for request objects was given to ZSQL
to allow funky parameters in the URL as well as the other usual special
methods such as manage and edit. Personally I think this is a bad idea and
always pass my parameters in as named arguments as Maciej suggests or as a
dictionary for neatness if there is a lot of them.
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,Linux,Solaris,MacOSX for free ! ::::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
Registered at Amtsgericht Duesseldorf: HRB 46611
More information about the Zope-DB
mailing list