Re: feed ZSQL "select" to a multiple selection property
Thanks to both. It worked. But now I curious if there is a need to have the ZSQL method at all, or if there is a way to query the database directly from within the script. thanks again, Daniel On 2 Sep 2003 at 20:24, Dieter Maurer wrote:
Daniel Ajoy wrote at 2003-8-28 18:08 -0500:
How can I feed a ZSQL "select" to a multiple selection property?
You can use "Formulator" or use an adapter (a Python Script) to your Z SQL Method.
The adapter would look like this:
return [r[0] for r in context.<yourZSQLMethod>()]
Dieter
From: Dustin Mitchell <dustin@ywlcs.org>
Subject: Re: [Zope] feed ZSQL "select" to a multiple selection property To: zope@zope.org Message-ID: <20030901230748.GX17963@eleanor.internal.ywlcs.org> Content-Type: text/plain; charset=us-ascii
Use an SQL query as below, then call it from a Python script, located within acquisition context, such as
--- rv = [] for row in old_zsql_method: rv.append(row.field1) return rv ---
Then give the name of your Python script as the default value of the "multiple" property.
Dustin
Daniel Ajoy wrote at 2003-9-2 19:09 -0500:
But now I curious if there is a need to have the ZSQL method at all, or if there is a way to query the database directly from within the script.
Stay with the Z SQL Method. It is the easiest approach. There are others, once you became an expert... Dieter
participants (2)
-
Daniel Ajoy -
Dieter Maurer