[Zope] Change ZSQLMethod connection id

Tino Wildenhain tino at wildenhain.de
Fri Dec 23 12:24:00 EST 2005


Fabio schrieb:
> Hi!
> in my zope application I call ZSQLMethods from python script. Is it possible 
> to set "connection id" property of a ZSQLMethod before call it?
> 
> How?
> ZSQLMethod.propertyItems() return only ('title','')

If you set it only one time, you should be able to read it from ZMI
page how to set it (just lookup the method call of the form
and the variables it takes)

If however you want to change it on every call, your ZODB is
going to bloat badly - every change is saved.

In this case you might want to create 2 folders and put
both database connection objects with identical ID
in each of them:

somewhere/aconnectionfolder/dbconnection
somewhere/bconnectionfolder/dbconnection

and set in all your ZSQL methods "dbconnection"
as connection (perhaps while you edit them, use
this path:

somewhere/aconnectionfolder/whereyourzsqlmethodis/yourzsqlmethod/manage_main

where "whereyourzsqlmethodis" does not have to be physically
there (read about Acquisition)

Now, if you want to use one or the other connection, just use:

context.somewhere.aconnection.pathtoyourzsqlmethods.yourzsqlmethod(params...)

or

context.somewhere.bconnection.pathtoyourzsqlmethods.yourzsqlmethod(params...)

while you can even parametrize the path as usually.

HTH
Tino


More information about the Zope mailing list