[Zope-PTK] Adding methods to new wizards

Mike Pelletier mike@digicool.com
Wed, 5 Apr 2000 14:21:37 -0400 (EDT)


On Sun, 26 Mar 2000, Yael Maguire wrote:

> I'm trying to create my own wizard and I'm having trouble adding an
> external python file to process the information. I have created a
> wizard called Challenge. In the view properties, I can list the
> method to be called from my file addChallenge, specified in a python
> file Challenge.py modeled after the NewsItem.py file (this is in the
> same directory as NewsItem.py).

  So, 'Challenge.py' defines a new PortalContent class called
'Challenge', and the Challenge Wizard is supposed to create instances
of this new class, correct?

  Before you can instantiate new PortalContent classes, they have to
be registered with the PTK.  See the bottom of NewsItem:

from Products.PTKBase.register import registerPortalContent
registerPortalContent(NewsItem,
                      constructors=(addNewsItem,),
                      action='Wizards/NewsItem',
                      icon="newsitem.gif")

  This code is executed when PTKBase's __init__.py module imports
NewsItem.  You will need similar registration code in your
Challenge.py module.  For it to get executed, you will need to import
your Challenge.py module from the __init__.py module.

  There is information about registration on the PTK Wiki.

  Once this is done, you can name the constructor you selected when
registering the class in the Wizard's Properties view.

  This still leaves you with a problem-- you've forked the PTK, and
you may have trouble tracking changes.  Rather than place your
Challenge code in the PTKBase Product, you should create your own
Product to place it in.  So long as you register the class as above,
it will be found by the PTK.

Mike.

-- 
Mike Pelletier                          email: mike@digicool.com
Mild mannered software developer          icq: 7127228
by day, super villain by night.         phone: 519-884-2434