SV: [Zope] Render SQL method as lines
Hmmm... not yet ! I was trying to convert a SQL method into lines, which as far as I can understand is newline terminated (LF?). I think that my attempt below returns CR/LF. When I try to insert a new property (multiple selection) in another object, and add my DTML method as the value parameter, zope says "Strings are not allowed as input to the in tag". If I specify the SQL method directly, I get the row objects (I think), and not the actual column. So I'd like to transform the SQL column into lines... Hope you understand what I mean ! Thanks -----Oprindelig meddelelse----- Fra: zope-admin@zope.org [mailto:zope-admin@zope.org]Pa vegne af tom smith Sendt: 20. marts 2001 18:14 Til: Kenneth Ellested; zope@zope.org Emne: Re: [Zope] Render SQL method as lines on 20/3/01 4:21 PM, Kenneth Ellested at ke@younameit.dk wrote:
How do I render a SQL method as lines ?
I'd like to make a DB lookup for a Multi-Selection property.
This is my DTML method (getNames is a SQL method): <dtml-in getNames> <dtml-var name> </dtml-in>
add... <dtml-call "RESPONSE.setHeader('Content-Type', 'text/plain')"> ...and it should work tom _______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Kenneth Ellested wrote:
Hmmm... not yet !
I was trying to convert a SQL method into lines, which as far as I can understand is newline terminated (LF?). I think that my attempt below returns CR/LF. When I try to insert a new property (multiple selection) in another object, and add my DTML method as the value parameter, zope says "Strings are not allowed as input to the in tag". If I specify the SQL method directly, I get the row objects (I think), and not the actual column. So I'd like to transform the SQL column into lines...
Hope you understand what I mean !
Thanks
The SQL method returns a list of brains. The DTML Method returns a string (by default). I would suggest using a python script to return a list of strings from the sql method like so: list = [] for row in context.sqlMethod(context.REQUEST): list.append(row.field) return list However, a lines property does not take a list as input, it takes newline delimited string, so the following python script might work better (untested): import string list = [] for row in context.sqlMethod(context.REQUEST): list.append(row.field) return string.join(list, '\n') -- | Casey Duncan | Kaivo, Inc. | cduncan@kaivo.com `------------------>
participants (2)
-
Casey Duncan -
Kenneth Ellested