Re: updating fields in a zsql method programmatically
"Charlie Clark" <[email protected]> Mon, 27 Aug 2007 21:59:47 +0200
| Newsgroups | gmane.comp.web.zope.database |
|---|---|
| Organization | eGenix.com |
| Message-ID | <[email protected]> |
Am 27.08.2007, 15:59 Uhr, schrieb onsombal <[email protected]>: > 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