[Zope] Running a script at Zope startup

Tino Wildenhain tino@wildenhain.de
Mon, 28 Jul 2003 16:29:02 +0200


Hi,

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?

Why on startup? You have to instantiate it on each thread which
is created. Why not just make the connection as soon as a method
is called on the object?

Imagine your object might be not actually loaded from ZODB on
Zopes startup.

something like:

class myFancyProxy:
	def __init__(self,id,proxyparams):
		self.id=id
		self.proxyparams=proxyparams

	def doSomething(self,args):
		if not hasattr(self,'_v_connection'):
			self.connect()
		self._v_connection.doSomething(args)
	def connect(self)
		self._v_connection=createConnectionSomeHow(self.proxyparams)



(Just a rough outline!)

HTH
Tino

> 
> Thanks
> 
> Herman
> 
> ----- Original Message -----
> From: "Tino Wildenhain" <tino@wildenhain.de>
> To: "Herman Geldenhuys" <hgeldenhuys@gmsonline.co.za>
> Cc: <zope@zope.org>
> Sent: Monday, July 28, 2003 9:35 AM
> Subject: Re: [Zope] Running a script at Zope startup
> 
> 
> 
>>
>>>----------
>>>From: Tino Wildenhain[SMTP:TINO@WILDENHAIN.DE]
>>>Sent: Monday, July 28, 2003 9:35:19 AM
>>>To: Herman Geldenhuys
>>>Cc: zope@zope.org
>>>Subject: Re: [Zope] Running a script at Zope startup
>>>Auto forwarded by a Rule
>>>
>>
>>Hi Herman,
>>
>>Herman Geldenhuys wrote:
>>
>>>EmailHi all!
>>>
>>>I have searched for a sollution, but could not find an appropriate way
> 
> to
> 
>>>execute a python script when Zope starts up.
>>>
>>>Does anybody know of a way that I am able to do this? What I basically
> 
> have,
> 
>>>is client objects residing inside Zope objects, that needs to connect to
>>>remote servers each time zope starts up. The client connections cannot
>>>persist in the ZODB, so I need to create them each time. The zope
> 
> objects in
> 
>>>this instance acts only as a proxy-type object.
>>
>>A common way to do this not at start up but soon as the object
>>is needed. Thats the way most DB adaptors do it.
>>Search for _v_* volatile attributes for a start.
>>
>>HTH
>>Tino Wildenhain
>>
>>
>>_______________________________________________
>>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 )
>