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. On a related question -- how does one determine the set of available connection ids? Thanks Jim Penny
Am Die, 2002-08-13 um 19.32 schrieb Jim Penny:
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. How about creating a new "bar" connection object with the same id?
On a related question -- how does one determine the set of available connection ids? look at lib/python/Products/ZSQLMethods/SQL.py:SQLConnectionIDs
Andreas
On Wed, Aug 14, 2002 at 12:33:50PM +0200, Andreas Kostyrka wrote:
Am Die, 2002-08-13 um 19.32 schrieb Jim Penny:
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 think that http://www.zopelabs.com/cookbook/1003271138 can be modified to do what I want. I will know later today.
I could swear that this has come up before, but I cannot find it.
How about creating a new "bar" connection object with the same id?
Very distasteful. Then I might see that I was working with the "foo adatper" when the "bar adapter" was really processing it, and acquisition could even disguise the fact. Ouch!
On a related question -- how does one determine the set of available connection ids?
look at lib/python/Products/ZSQLMethods/SQL.py:SQLConnectionIDs
Thanks. The context I was in was so bizarre that I hope no one else needs this. (I have a home-brew UserFolder that holds a connectionID, I wanted to change it over to another DA without deleting and re-installing the UserFolder.) Anyway, on the off chance that anyone else will ever need something like this, I did an external method, whose guts was: self.acl_users.connection_id=self.this().aq_acquire('Bar_database_connection') See, easy! (Actually, it was...) Thanks again. Jim
Andreas
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
participants (2)
-
Andreas Kostyrka -
Jim Penny