[Zope-DB] updating fields in a zsql method programmatically
dieter at handshake.de
Mon Aug 27 16:14:46 EDT 2007
onsombal wrote at 2007-8-27 06:59 -0700:
>It's easy to insert and update Z SQL Methods directly from form field
>It's easy to read form field results (e.g. request.field2) and do
>I am struggling to understand how one can change a form field result with a
>computed value from a python script.
You use keyword parameters in the call of your "ZSQL Method".
The signature of a "ZSQL Method"s "__call__" method ("__call__" is the method
called when you call an object) is:
def __call__(self, REQUEST=None, __ick__=None, src__=0, test__=0, **kw):
"""Call the database method
The arguments to the method should be passed via keyword
arguments, or in a single mapping object. If no arguments are
given, and if the method was invoked through the Web, then the
method will try to acquire and use the Web REQUEST object as
the argument mapping.
The returned value is a sequence of record objects.
When you do not pass (unknown) keyword arguments (more precisely, if "kw"
is empty), then the ZSQL method uses "REQUEST" as default.
That the usual way, how a ZSQL method gets values from the request.
When you have changed something, then you can change the value
in "REQUEST" (less advicable) or pass *all* parameters via keyword
arguments (much better because more explicit).
More information about the Zope-DB