[Zope] Changing DA
Jim Penny
jpenny@universal-fasteners.com
Wed, 14 Aug 2002 16:09:06 -0400
On Tue, Aug 13, 2002 at 01:32:33PM -0400, Jim Penny wrote:
> Suppose, I have many ZSQL methods using the foo DA, and want to switch,
> or at least test the bar DA.
>
> How do I programatically make the switch?
>
> I could swear that this has come up before, but I cannot find it.
OK, this does the job
External method--
def switch_sql_connectionid(self):
objs = self.ZopeFind(self.this(), obj_metatypes=['Z SQL Method'],
search_sub=1)
message=''
for path, method in objs:
title=method.title
conn_id=method.connection_id
args=method.arguments_src
body=method.src
new_conn_id='Bar_database_connection'
message+='Changing %s from conn_id %s to conn_id%s'%(path,
conn_id, new_conn_id)
method.manage_edit(title, new_conn_id, args, body)
message +='.\n'
return message
Notes:
1) It is indeed a connection id that you need here, and not a
connection object.
2) search_sub=1 implies recursive, search_sub=0 imples this folder
only.
Jim Penny