[Zope] Running a script at Zope startup

Herman Geldenhuys hgeldenhuys@gmsonline.co.za
Mon, 28 Jul 2003 14:36:19 +0200


Thanks.

I understand. The only "messy" solution I have thusfar is something like
this:

...at bottom of module in product...

def installConnections():
    def install():
        #1) get zope app object
        #2) loop through zope objects and create connections manually
        ...
    thread.start_new(install, ())

ThreadedAsync.register_loop_callback(installConnections)
>

Herman

Lbh pna'g gehfg lbhe rlrf vs lbhe vzntvangvba'f bhg bs sbphf. -Znex Gjnva

----- Original Message -----
From: "Tino Wildenhain" <tino@wildenhain.de>
To: "Herman Geldenhuys" <hgeldenhuys@gmsonline.co.za>
Sent: Monday, July 28, 2003 4:38 PM
Subject: Re: [Zope] Running a script at Zope startup


> Hi Herman,
>
> Herman Geldenhuys wrote:
> > Hi
> >
> > My problem is that the client connection must be started as soon as Zope
> > starts up. Ie, the attribute must be initialized prior to accessing it
from
> > within the Zope context. As soon as Zope starts, my client connection
must
> > be made, so that the remote server via a persistent connection to the
> > client, can invoke callback methods when an event occurs on the server's
> > side. So, the connection attribute is rarely ever called from within the
> > same "process". Is'nt there a "startup" event for Zope(event indication
all
> > modules are finished loaded)?
>
> This is not possible this way.
> Either you change your server to "plant" a method on it which
> calls via HTTP (for example XMLRPC) zope when the event occurs
> or you have to create a separate thread which lives outside the
> ZODB-Connection (somewhat like Zopes FTP server)
>
> Persistent connections from within a published request
> are impossible. (And make no sense either)
>
> Regards
> Tino
>
> >
> > Thanks again.
> >
> > Herman
> >
> > Lbh pna'g gehfg lbhe rlrf vs lbhe vzntvangvba'f bhg bs sbphf. -Znex
Gjnva
> >
> > ----- Original Message -----
> > From: "Alexis Roda" <arv@si.urv.es>
> > To: "Herman Geldenhuys" <hgeldenhuys@gmsonline.co.za>
> > Cc: "zope" <zope@zope.org>
> > Sent: Monday, July 28, 2003 1:57 PM
> > Subject: Re: [Zope] Running a script at Zope startup
> >
> >
> >
> >>
> >>>----------
> >>>From: Alexis Roda[SMTP:ARV@SI.URV.ES]
> >>>Sent: Monday, July 28, 2003 1:57:09 PM
> >>>To: Herman Geldenhuys
> >>>Cc: zope
> >>>Subject: Re: [Zope] Running a script at Zope startup
> >>>Auto forwarded by a Rule
> >>>
> >>
> >>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)
> >>--------------------------------------------------------------------
> >>
> >>
> >>_______________________________________________
> >>Zope maillist  -  Zope@zope.org
> >>http://mail.zope.org/mailman/listinfo/zope
> >>**   No cross posts or HTML encoding!  **
> >>(Related lists -
> >> http://mail.zope.org/mailman/listinfo/zope-announce
> >> http://mail.zope.org/mailman/listinfo/zope-dev )
> >>
> >
> >
> >
> > _______________________________________________
> > Zope maillist  -  Zope@zope.org
> > http://mail.zope.org/mailman/listinfo/zope
> > **   No cross posts or HTML encoding!  **
> > (Related lists -
> >  http://mail.zope.org/mailman/listinfo/zope-announce
> >  http://mail.zope.org/mailman/listinfo/zope-dev )
> >
>
>