[Zope-PTK] event ZClass

Nolan Darilek nolan_d@bigfoot.com
Mon, 06 Mar 2000 15:07:08 -0600


>>>>> "Timothy" == Timothy Wilson <wilson@visi.com> writes:

    Timothy> Hi everybody, I remember that someone mentioned they were
    Timothy> working on an event ZClass. Am I remembering correctly?

Yep.

    Timothy> Is so, I'd love to hear how it's coming because I'm very
    Timothy> interested in something similar.

Ok. I'm not saying that this is the "right" way; it may be possible to
do this from the web via Z classes. I basically gave up and hacked the
PTK Python code directly, and I probably did it in a
not-very-nice-way, but oh well, it works. :)

I wanted my Event class to be similar to a NewsItem but with an extra
eventdate property, so that I could use dtml-calendar to create quick
links to events. So I copied NewsItem.py and began hacking. "Hacking"
in this case was basically replacing all occurences of NewsItem, news
item and News Item with Event. :) I also modified the constructor to
take an extra eventdate argument.

Then I hacked PTKBase/__init__.py. I changed a portion of it to look
like:

        context.registerBaseClass(NewsItem.NewsItem, 'News Item')
        context.registerBaseClass(Document.Document,'Document')
        context.registerBaseClass(Link.Link, 'Link')
        context.registerBaseClass(Event.Event, 'Event')

I then copied the News Item wizard, changed references from News to
Event, and added code to support inputing a date. Then I copied
newsEdit.dtml and added a similar input field, with
value="&dtml-eventdate;", which made event editting work
nicely. Finally, I hacked the Recent News pages so that the meta_data
in the Z catalog search would search for ['News Item', 'Event']
instead of just news, since they're both intended to serve identical
purposes. And that was it; I now have an Event class which serves my
purposes nicely. Hopefully I haven't broken compatibility with future
versions of the PTK; I hate modifying code locally and making my
version of something nonstandard, even if it is only slightly so.