Mailing List Archive

[Zope-PTK] Adding methods to new wizards
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). This didn't seem to work :

Error Type: AttributeError
Error Value: 'None' object has no attribute 'has_key'

Then I tried adding an external method:

id: addChallenge
title:
method: addChallenge
file:PTKBase.Challenge

When I copied Challenge.py to the Extensions folder in PTKBase. It found
the file, but complains:

Error Type: KeyError
Error Value: __name__

Any light that could be shed on this situation would be very appreciated.


Thanks,

Yael Maguire
Re: [Zope-PTK] Adding methods to new wizards [ In reply to ]
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