Change ZSQLMethod connection id
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','') Thanks, Fabio -- Dott. Fabio Marcone 2T srl Telefono +39 - 0871- 540154 Fax +39 - 0871- 571594 Email fabio.marcone@duet.it Indirizzo Viale B. Croce 573, 66013 Chieti Scalo (CH)
--On 23. Dezember 2005 13:33:08 +0100 Fabio <fabio.marcone@duet.it> wrote:
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','')
perhaps zsql_method.connection_id = '....' might to the job. See DA.py -aj
Andreas Jung wrote:
--On 23. Dezember 2005 13:33:08 +0100 Fabio <fabio.marcone@duet.it> wrote:
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','')
perhaps
zsql_method.connection_id = '....' might to the job. See DA.py
-aj
Fabio, This, I think, is something I found in ZopeLabs some time ago. --------------------------------------------------------------------------------- objs = container.ZopeFind(container, obj_metatypes=['Z SQL Method'], search_sub=1) # module: pyPsycopgPropertyChanges path_list = [] for path, method in objs: title = method.title conn_id = 'Psycopg_database_connection' args = method.arguments_src body = method.src method.manage_edit(title, conn_id, args, body,max_rows=5000) path_list.append(path) header = "Fixed up the following methods - %s out of total sql count of %s"%(str(len(path_list)), str(len(objs))) body="<br><br><ul><li>%s</li></ul>"%join(path_list, '</li><li>') return header+body --------------------------------------------------------------------------------- HTH, David
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
participants (4)
-
Andreas Jung -
David H -
Fabio -
Tino Wildenhain