[Zope] Zope Proxy Objects
Christian Tismer
tismer@tismer.com
Sun, 15 Jul 2001 23:45:52 +0200
Howdy,
"J. Cameron Cooper" wrote:
>
> >
> >
> >Any ideas?
> >Here the problem again: Use a Windows ODBC database from Zope on Linux.
> >Only OpenSource products can be used.
> >
> If you need to see the database connection on your Linux Zope you could
> try one of the Linux-running ODBC connections to go straight to the
> server (search this list for links) or perhaps you could use ZEO or some
> other scheme to mount the Storage of your other Zope to your Linux Zope.
>
> Perhaps less complicated would be the XML-RPC Proxy product
> (http://www.zope.org/Members/dshaw/XMLRPCProxy). Dunno if this can proxy
> DB connections. If not, perhaps you could create a proxying DB
> Connection, which would use XML-RPC to call the one on the other server.
I just did it.
There is now a product called "ZODBCPDA" which is a proxy for ODBC
databases. It works quite fine, lathough I think it can be enhanced.
Due to my limited understanding of ZClasses and other Zope specifics,
I used the following technique:
On windows, there is a Zope application with a top-level folder called
ODBCProxy. Inside the folder, there is a couple of external methods.
The external methods are sitting in a Python file in the Extensions
directory. This file imports the Products.ZODBCDA.db module and publishes
all of its functions with a few additional parameters, to identify the
instance.
Then, I made a copy of ZODBCDA a ZODBCPDA (the proxy) for Linux. It also
works from Windows, if you want to connect to a different Win machine.
This proxy da redirects all its methods to the target machine which
I explained above.
It works quite well. Browsing a database is quite slow, since there
seem to be many DB calls in the tree object. But retrieving a large
set of records is nearly as fast as with a local database.
Communication is done with XMLRPC. This is not too efficient, but
works well, since usually a whole dataset is returned as one large
string, and the XML parsing becomes cheap.
There was some trouble with XMLRPC, especially I had to take
care of default parameters: None is not supported. Furthermore,
XMLRPC can take positional arguments, only. After I realized
this, I could quite easily hack around these limitations, and
the whole product was functional after a very long session
from yesterday to noon today, mostly because I'm not used to Zope.
When retrieving data not as string but as a big set of records,
things become slow, since XMLRPC is not too efficient, and the
representation of many objects via XML is quite large.
I will try to improve this by pickling large record sets.
Unfortunately, XMLRPC also doesn't handle binary data (which is
the most effective pickling approach), so I would have to add
an base64 step as well.
I think to publish this product in a couple of days as it is.
What I'd like to do in the future:
- extend it to support just any database
- add a binary transfer protocol to XMLRPC which is efficient
- make the solution more elegant, without external methods.
As a first step to make ODBC usage more similar under Windows
and Linux, I will try to make ZODBCDA and ZODBCPDA into one
single adaptor with an additional "Proxy" property. This way,
the same adaptor can be used, regardless whether the database
is local or remote.
I would appreciate if someone would give me a hint how to write
this in a "cleaner" way, without using a folder and external
methods.
Thanks to all who provided sugestions and advice.
I am becoming a Zope programmer.
ciao - chris
--
Christian Tismer :^) <mailto:tismer@tismer.com>
Mission Impossible 5oftware : Have a break! Take a ride on Python's
Kaunstr. 26 : *Starship* http://starship.python.net/
14163 Berlin : PGP key -> http://wwwkeys.pgp.net/
PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF
where do you want to jump today? http://www.stackless.com/