I want the ZEvent class of ZScheduler to be subclassable by ZClasses. I think I did everything specified in http://www.zope.org/Documentation/Guides/ZDG-HTML/ZDG.6.3.11.html to make a subclassable class (i.e. registered it with registerBaseClass()). However when I tried to make a ZClass, ZEvent was not in the list of base classes. What else do I need to do? -- Thanks -- Loren
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)
I want the ZEvent class of ZScheduler to be subclassable by ZClasses. I think I did everything specified in
http://www.zope.org/Documentation/Guides/ZDG-HTML/ZDG.6.3.11.html
to make a subclassable class (i.e. registered it with registerBaseClass()). However when I tried to make a ZClass, ZEvent was not in the list of base classes. What else do I need to do?
-- Thanks -- Loren
class BaseZEvent(CatalogAware, DTMLMethod): meta_type = 'ZEvent' default_catalog = ScheduleID def __init__(self, id, title = '', file = ''): DTMLMethod.__init__(self, file, __name__ = id) manage_options=({'label':'Edit', 'action':'manage_main'}, {'label':'Upload', 'action':'manage_uploadForm'}, {'label':'View', 'action':''}, {'label':'Proxy', 'action':'manage_proxyForm'}, {'label':'Security', 'action':'manage_access'}, ) __ac_permissions__=( ('View management screens', ( 'manage_editForm', 'manage', 'manage_main', 'manage_uploadForm', 'document_src', 'PrincipiaSearchSource')), ('Change DTML Methods', ('manage_edit', 'manage_upload', 'PUT')), ('Change proxy roles', ('manage_proxyForm', 'manage_proxy')), ('View', ('__call__', '')), ('FTP access', ('manage_FTPstat','manage_FTPget','manage_FTPlist')), ) manage_editForm=HTMLFile('documentEdit', globals()) manage=manage_main=manage_editDocument=manage_editForm 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')
From: "Loren Stafford" <lstaffor@dynalogic.com>
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)
I want the ZEvent class of ZScheduler to be subclassable by ZClasses. I think I did everything specified in
http://www.zope.org/Documentation/Guides/ZDG-HTML/ZDG.6.3.11.html
to make a subclassable class (i.e. registered it with registerBaseClass()). However when I tried to make a ZClass, ZEvent was not in the list of base classes. What else do I need to do?
<GIANT SNIP> Sorry Loren, I have absolutely no idea. ZCatalog does this for CatalogAware, so this should work as well. Have you tried my suggestion of useing the Python Debugger? Or did that email never go because of one of my machine crashes? 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 ---------------------------------------------
On Tue, 7 Mar 2000, Loren Stafford wrote:
I still haven't found an answer to this question. Anyone have any idea why or how to figure out?
[snip]
class BaseZEvent(CatalogAware, DTMLMethod): meta_type = 'ZEvent' default_catalog = ScheduleID
def __init__(self, id, title = '', file = ''): DTMLMethod.__init__(self, file, __name__ = id)
manage_options=({'label':'Edit', 'action':'manage_main'}, {'label':'Upload', 'action':'manage_uploadForm'}, {'label':'View', 'action':''}, {'label':'Proxy', 'action':'manage_proxyForm'}, {'label':'Security', 'action':'manage_access'}, ) __ac_permissions__=( ('View management screens', ( 'manage_editForm', 'manage', 'manage_main', 'manage_uploadForm', 'document_src', 'PrincipiaSearchSource')), ('Change DTML Methods', ('manage_edit', 'manage_upload', 'PUT')), ('Change proxy roles', ('manage_proxyForm', 'manage_proxy')), ('View', ('__call__', '')), ('FTP access', ('manage_FTPstat','manage_FTPget','manage_FTPlist')), )
manage_editForm=HTMLFile('documentEdit', globals()) manage=manage_main=manage_editDocument=manage_editForm
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')
Unless my eyes just aren't seeing something, you are missing a call to registerBaseClass. In the __init__.py for your Product, put: import BaseZEvent def initialize(context): context.registerBaseClass(BaseZEvent.BaseZEvent, BaseZEvent.BaseZEvent.meta_type) Note that registerClass is NOT the same as registerBaseClass. --Jeff --- Jeff K. Hoffman 704.849.0731 x108 Chief Technology Officer mailto:jeff@goingv.com Going Virtual, L.L.C. http://www.goingv.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. Also, I posted a message to the list a while back explaining this, you might want to read that. -Michel
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 ---------------------------------------------
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 )
participants (4)
-
Jeff K. Hoffman -
Loren Stafford -
Martijn Pieters -
Michel Pelletier