[Zope-dev] Why is ZEvent not ZClass subclassable?

Loren Stafford lstaffor@dynalogic.com
Tue, 7 Mar 2000 15:33:40 -0800


Thanks, Martin.

Michel, I've got the ZScheduler (formerly Martijn's project) functioning at
a basic level. Now, thanks to your help and that of Martijn and Jeff, I've
got the ZEvent (scheduled DTML method) class registering not only for the
"Available Object" list but also for the ZClass "Base classes"  list.

To keep anyone else from overlooking registerBaseClass as separate from
registerClass, any Zope API documentation should explicitly state in the
sections for both methods:

"""
There are two registration methods for Products to use in their __init__.py
modules. A Product may need to use either or both of them:

  * registerClass, which adds the class to the "Available Objects" list.

  * registerBaseClass, which adds the class to the ZClass "Base classes"
list
"""

Did I get it right this time?

I've also added a "reschedule" method to the ZEvent, which gets called when
ZScheduler triggers the event. Right now it simply disarms the event. I may
(or may not) enhance "reschedule" to handle repetetive events in the base
class. But assuming "reschedule" can be overridden by a ZClass, the ZClass
can do whatever rescheduling it wants. Soon as I get that assumption tested,
I'll make another release. Then ZClass-based products can start using
scheduled DTML methods in useful ways.

-- Thanks for your help
-- Loren

----- Original Message -----
From: Martijn Pieters <mj@digicool.com>
To: Michel Pelletier <michel@digicool.com>
Cc: zope-dev <zope-dev@zope.org>
Sent: March 07, 2000 12:57 PM
Subject: Re: [Zope-dev] Why is ZEvent not ZClass subclassable?


> From: "Michel Pelletier" <michel@digicool.com>
> > Loren Stafford wrote:
> > >
> > > I still haven't found an answer to this question. Anyone have any idea
> why
> > > or how to figure out?
> > >
> > > Below is the code that defines the ZEvent class (minus some of its
> methods)
> > >
> > > >
> > >
> > > class BaseZEvent(CatalogAware, DTMLMethod):
> >
> >     " synatically legal snip "
> >
> > > class OneTimeZEvent(BaseZEvent):
> > >   #meta_type = 'Onetime ZEvent'
> > >
> > > default__class_init__(OneTimeZEvent)
> > >
> > > # code that registers above class
> > >       context.registerClass(
> > >         ZEvent.OneTimeZEvent,
> > >         permission = 'Add ZEvent',
> > >         constructors = (
> > >           ZEvent.manage_addOneTimeZEventForm,
> > >           ZEvent.manage_addOneTimeZEvent),
> > >         icon = 'www/OneTimeZEvent.gif')
> >
> >
> > Loren, first, there is no 'def initialize(context)" here.  The last
> > stanza of your code is actually syntacically incorrect.  I don't see how
> > you are defining a fucntion.  Second, I don't see you calling
> > context.registerBaseClass.  Third, your initialize function should be in
> > your Product's __init__.py file.  Examine
> > lib/python/Products/ZCatalog/__init__.py to see how ZCatalog registers
> > itself and CatalogAwareness as Base Classes.
>
> He copied the code out of the __init__.py file, out of the (bigger)
> initialize function. His code works when you download it from Zope.org. I
> gave him the benefit of the doubt and assumed he had forgotten to copy in
> the call to registerBaseClass.
>
> Martijn Pieters
> | Software Engineer    mailto:mj@digicool.com
> | Digital Creations  http://www.digicool.com/
> | Creators of Zope       http://www.zope.org/
> |   The Open Source Web Application Server
> ---------------------------------------------
>
>
> _______________________________________________
> Zope-Dev maillist  -  Zope-Dev@zope.org
> 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 )
>