[Zope] Change ZSQLMethod connection id

David H bluepaul at earthlink.net
Fri Dec 23 12:05:19 EST 2005


Andreas Jung wrote:

>
>
> --On 23. Dezember 2005 13:33:08 +0100 Fabio <fabio.marcone at 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





More information about the Zope mailing list