[Zope-DB] Changing a Z SQL Method's connector dynamically
Jose Carlos Balderas Alberico
josecarlos.balderas at gmail.com
Fri Jun 30 02:50:26 EDT 2006
Greetings. I have a question regarding Z SQL Methods and their connector.
I need to be able to change their connector dynamically, using a python
script, which will select the connector depending on the parameters passed
to the script. I'll give you an example:
Suppose I have three connectors, each one of them pointing to different
databases (they all have the same tables and fields).
I also have one Z SQL Method that does "Select * from table". When I create
such method, I provide a connector using the dropdown list (that'll be the
connector by default).
I need to create a script, called selectConnector.py, which receives an
integer parameter (n). If n equals 1, the first connector will be chosen for
the Z SQL Method; if n equals 2, the second one will be chosen, and so on...
I've tried accesing the connection_id property from the Z SQL Method. I can
read it to a variable doing the following:
conn = context.zSQLMethod.connection_id
That way, I'll have a variable conn containing the connector id. What I need
to do is change that connector. If I code
context.zSQLMethod.connection_id = <inserts name of new connector here>
I get a TypeError: attribute-less object (assign or del).
Please, give me a hand, and tell me a way to modify that property from a
Thank you very much in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Zope-DB