[Zope-dev] poor mans solution to startup folder
Chris McDonough
chrism@zope.com
Thu, 10 Jan 2002 00:33:50 -0500
That looks like a workable solution!
This can also be done in a Product by getting hold of the supersecret
attribute of the "context" object that is passed in to "initialize" which is
the database connection (or maybe it's the root root object.. in either
case, given either, you can get the other). It might be better that way in
order to keep the logic out of the Zope init routine and in a separate
product so it can be modified outside of Zope and used with various Zope
versions until its baked enough to make it in...
----- Original Message -----
From: "Darrell Gallion" <dgallion1@yahoo.com>
To: "Chris McDonough" <chrism@zope.com>
Cc: <zope-dev@zope.org>
Sent: Wednesday, January 09, 2002 7:13 PM
Subject: Re: [Zope-dev] poor mans solution to startup folder
> External methods aren't the best solution I know.
> It wasn't obvious to me how to call python scripts at
> this point. For that matter if this is a good point to
> do this kind of thing. Or how to hook the startup
> event with a product.
>
> Added these lines to the bottom of initialize(app) in
> application.py
>
>
>
> # Ensure that a startup folder exists
> if not hasattr(app, 'startup'):
> from OFS import Folder
> Folder.manage_addFolder(app, id='startup',
> title='Startup')
> get_transaction().note('Added startup folder')
> get_transaction().commit()
>
> # Call any external methods found in the startup
> folder
> # Only call external methods
> startup = getattr(app, 'startup')
> for obj in startup.objectIds():
> obj=getattr(startup, obj)
> if hasattr(obj,'__call__') and
> obj.__class__.__name__=='ExternalMethod':
> obj(app)
>
>
> =====
> Darrell Gallion
>
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Send FREE video emails in Yahoo! Mail!
> http://promo.yahoo.com/videomail/
>