[Zope-dev] How to develope a ZObject to connect to an socket server?
Casey Duncan
casey@zope.com
Thu, 22 Aug 2002 09:47:53 -0400
On Thursday 22 August 2002 09:04 am, Juan Carlos CORU=D1A wrote:
> Hi all!
>=20
> I'm trying to develope a zope object that connects to a external socket
> server in order to comun=EDcate with it and receive some events (Maybe =
I
> need a thread to process events).
That's probably a good idea if not necessary if Zope must respond to inco=
ming=20
events other than over HTTP.
=20
> The problem is how to establish the connection at the start of zope and
> to disconnect at the end. After some test assigning the socket server
> object to _v_ variables in the zope object, it missed the connection
> after a while. It seems that it can't maintain the reference stored in
> the _v_ variable.
I would recommend using module level global variables instead. Volatile v=
ars=20
are just that. If a persistent object with volatiles gets unloaded by the=
=20
ZODB (which can happen at any time arbitrarily), its volatiles go bye bye=
=2E=20
Volatiles are also thread specific. Module globals are shared across thre=
ads,=20
which may be a good or bad thing depending on your situation ;^).
=20
> I thing that the behaviour is something like database connections and
> I'm looking into some database connection objects to find out the
> mechanism used.
Yup. Except they don't receive events except in response to a request com=
ing=20
from Zope.
-Casey