[Zope-PTK] Adding other types of news items

Dan L. Pierson dan@sol.control.com
15 Feb 2001 09:49:34 -0500


Jens Vagelpohl <jens@digicool.com> writes:

> What you need to do is go to the PTKDemo directory in your zope install (on
> the file system) and check out the NewsItem.py file. you would need to
> create a new python class for your "Market News" object and give it a
> distinct add method and meta type and all that, and then you can override
> whatever is necessary in that new class. once you are done with that you
> need to go back to the types tool and put the name of the add method into
> the field "Factory method in product".
> 
> Make sure to add the correct product registration information for your
> Market News object in the right places (like in __init__.py under PTKDemo),
> just grep for NewsItem and emulate how it is being done.

If you're going to do this, I'd really advise creating a new Python
product for your modifications.  What I did was:

1. Create a new directory named 'PTKCCom' under Products.

2. Copy __init__.py and the .py files I wanted to subclass or clone
from PTKDemo to PTKCCom.

3. Rename my .py files from Demo*.py to CCom*.py.  This is optional,
but will help reduce confusion later.

4. Edit my copied __init__.py to remove all references to stuff I
wasn't doing and add my new files.

5. Edit my copied files to subclass from the PTKDemo classes
(e.g. make CComMembershipTool subclass from DemoMembershipTool instead
of MembershipTool).  Obviously a bunch of imports need to be fixed up;
watch out for ones that used to import from the local product
directory.

6. Delete all members that I don't plan to override from my new
subclasses.

This should result in a structure that will survive future PTK changes
a lot better than changing code in PTK directories.  It really isn't
hard to do.

Dan Pierson