Re: [Zope-dev] poor mans solution to startup folder

2002-01-09 Thread Chris McDonough

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" <[EMAIL PROTECTED]>
To: "Chris McDonough" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
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/
>


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] poor mans solution to startup folder

2002-01-09 Thread Darrell Gallion

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/

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )