parameter transfer to a zsql-method (lists, dictionaries etc.)
Hi, I have problems with the parameter transfer to a zsql-method: With the Test - Tab of the ZMI the following ZSQL-method works fine without passing any parameters (i.e. with the default values) But if I call it with "return db.sql.device_list()", with "db.sql.device_list(['col1','col2'])" or with "db.sql.device_list(columns=['col1','col2'])" from a script I get the given errors. Can anybody enlight my understandig of how to pass parameters (e.g. lists, dictionaries) to zsql-methods especially so that they will work in an dtml-in construct? That would be very helpfull. --Thanks, Elena my ZSQL-Method: <params>columns:list:string=* where:string="" sort_col:string="" sort_reverse:int=0</params> SELECT <dtml-in columns prefix=column> <dtml-var column_item fmt=sql-quote><dtml-unless column_end>, </dtml-unless> </dtml-in> FROM device_list the error details: Error Type: InError Error Value: Strings are not allowed as input to the in tag. Error error_tb: Traceback (innermost last): * Module ZPublisher.Publish, line 98, in publish * Module ZPublisher.mapply, line 88, in mapply * Module ZPublisher.Publish, line 39, in call_object * Module Shared.DC.Scripts.Bindings, line 252, in __call__ * Module Shared.DC.Scripts.Bindings, line 283, in _bindAndExec * Module Products.PythonScripts.PythonScript, line 315, in _exec * Module Script (Python), line 9, in test <PythonScript at /tomaxx/db/s/test> Line 9 * Module Shared.DC.ZRDB.DA, line 415, in __call__ * Module DocumentTemplate.DT_String, line 474, in __call__ * Module DocumentTemplate.DT_In, line 636, in renderwob InError: Strings are not allowed as input to the in tag.
Can anybody enlight my understandig of how to pass parameters (e.g. lists, dictionaries) to zsql-methods especially so that they will work in an dtml-in construct? That would be very helpfull.
my ZSQL-Method:
<params>columns:list:string=* where:string="" sort_col:string="" sort_reverse:int=0</params>
the error details:
Error Type: InError Error Value: Strings are not allowed as input to the in tag. Error error_tb: ...
InError: Strings are not allowed as input to the in tag.
I think your parameter construction is wrong. You're telling Zope that a list is a string, and furthermore, to iterate over a string, which won't work. Try columns:list or simply columns since you probably don't *need* parameters. --jcc -- "My point and period will be throughly wrought, Or well or ill, as this day's battle's fought."
participants (2)
-
Elena Schulz -
J Cameron Cooper