[Zope-dev] [Zope] ZSQL Methods in Z Classes

Shai Berger shai@aristocart.com
Wed, 16 May 2001 21:25:15 +0300


Hi Guys,

I wanted to use ZSQL Methods in Z Classes to share code between different
parts of a large project. The different parts need to use similar, but
separate, database namespaces, but I still wanted to use the same methods.

Now, ZSQL Methods treat their Database connection ID, for some reason,
on a par with their source -- it is not a parameter. You are not supposed
to run one ZSQL Method on two connections. (One can try to acquire, restricting
yourself to the same ID name in different folders; I think this will not work,
and the ZSQL methods will get to their original DB connection first).

I tried to bypass this limitation, by defining a forwarding database adapter.
The idea was that this adapter's connection string would point to a resource
(property or method) which will specify the actual connection. The idea was
that in a ZClass, I could have this be a pythonscript which will look into
an instance property sheet, thereby allowing different instances to use
different connections.

This seemed to work very nicely at first: After the ZClass with the forwarding
adapter and pythonscript was installed into a folder, all its methods worked
like magic. I was very happy.

Then we restarted Zope, and ever since, it seems like the Adapter is being
called by the ZSQL Methods without any acquisiotion context.

Could you help show me what went wrong?

BTW: I intended to make the forwarding DA a product, and to ship with it 
a base ZClass for ZSQL methods-using ZClasses, which I wanted to call "ZSQL Class".
But even before the current problems, I was halted by the fact that if you
define a database connection in a ZClass, ZSQL Methods in derived classes cannot
use it.

In fact, even ZSQL Methods in the same class as the adapter act funny -- you
can set it as their connection, but in the source they say "connection not found",
and you can't test them in the class context (even when they don't rely on instance
resources).

Hope this is informative enough, and that others have thought of these problems,

Shai.

_______________________________________________
Zope maillist  -  Zope@zope.org
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )