[Zope] Running a script at Zope startup

Alexis Roda arv@si.urv.es
Mon, 28 Jul 2003 13:57:09 +0200


Herman Geldenhuys wrote:
> Thanks Tino!
> 
> I understand that I need to initialize a _v_ attribute each time I create my
> client connection, seeing that it cannot be stored in the ZODB. My problem
> is that I need a way to initiate that attribute at Zope's startup. Lets say
> that there are certain ZOPE objects in the hierarchy of ZOPE. I need to
> initialize all these objects _v_clientConnection attributes at Zope's
> startup. Does anybody know of a way?

I have not followed the thread, so I may be missing something, but I 
think that Tino's answer is right. You may achieve this defining a 
getter method, something like:

def get_client_connection(self) :
   if not hasattr(self, "_v_clientConnection") :
     self._v_clientConnection = xxxxx
   return sef._v_clientConnection

if you access this attribute through the method, and never directly, 
you'll always get a "valid" client connection.




HTH
-- 
                                   ////
                                  (@ @)
---------------------------oOO----(_)----OOo------------------------
         Los pecados de los tres mundos desapareceran conmigo.
Alexis Roda - Universitat Rovira i Virgili - Reus, Tarragona (Spain)
--------------------------------------------------------------------