[Zope] Simple question?
Terry Hancock
hancock at anansispaceworks.com
Sat Sep 13 15:04:41 EDT 2003
On Friday 12 September 2003 03:56 pm, Tiller, Michael
(M.M.) wrote:
> "What I really want is a new class of 'Folder' objects
> but that display, for example, some additional
> information when rendered". In other words,
> variations on the existing content types.
That's probably the most common case. The second
most is probably that you have a folder that is specialized
to hold a certain kind of object, so you have your
product create both types.
> It appears that I can use both ZClasses and Python
> products to do this.
Yeah, it seems that way, but in my experience it's not
true -- just go straight to writing a Python Product.
ZClasses are supposed to be an easier way, but I
find them actually harder -- and the result is apparently
not as flexible. So after a few failed attempts with
ZClasses, I just learned how to make products, and
my life got much easier.
I've attached a simple product you may find educational
to read. It makes a special folder type, and a special
content type to go into it. It just adds some meta data to
the content type and two special view methods to the
folder type.
Bear in mind this is still development code, and I haven't
checked it very thoroughly -- all I will assert is that it
will actually load-up into Zope and has the basic properties
I described above. I have no security declarations in this
code (it's kind of instructive, I think, to see what happens
when a product is written this way -- which is basically
that it's wide-open). That'll get fixed before I release
it. This is just an illustration for you to see about what
level of complexity a nearly-trivial product is (actually,
yes, it could get more trivial than this, but this is one
that is actually extended in a somewhat useful way, which
is a better gauge of what you're going to wind up with).
> My problem is that I'm working with Plone/CMF content
You're on your own with Plone/CMF, I don't know it.
> Anyway, I'm not asking somebody to tell me, step by
> step, how to do this (although I wouldn't mind :-), just
> some suggestions, pointers, etc. to help me get going.
Although ZC folks keep telling me it's obsolete, I find the
Zope Developer's Guide at:
http://www.zope.org/Documentation/Books/ZDG/current
to be quite succinct and direct about writing products.
It's the source I recommend you to start from.
Be prepared to spend a few hours on it, though.
If you try to rush too much, you'll get frustrated.
Product writing requires a bit of boilerplate (as you can
see from my example), and that strikes me as a bit
inefficient, but it really isn't too bad. Probably someone
could write a product to make it easier, and I think a few
people have tried, but I haven't found their efforts to be
that effective in reducing the difficulty of it, so I stick
to the straightforward approach in the ZDG.
Cheers,
Terry
[CC'd to list without the attachment]
--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks http://www.anansispaceworks.com
More information about the Zope
mailing list