[Zope] Newbie Questions - many-many relationships? Zope 2 or 3?
Jim Vine
jim_a_vine at yahoo.co.uk
Fri Jul 1 18:51:07 EDT 2005
Hello again,
So, following the recommendations from the board I
have settled on "route 3" - developing a Python
Product, using Zope 3. I've been refering a lot to the
Zope 3 Book (particularly chapter 13 onwards) and have
progressed somewhat.
I've created a "PropertyFolder" class, which can hold
Property obects, and following the example in the book
I've been able to make it hold *only* Property
objects.
My "Property" class is proving a little more
difficult, however. When I've tried to make it along
the same lines as the "message" class in the book, I
run into difficulties - it seems to be some sort of
problem with inheriting from multiple classes /
interfaces. My workaround has been that I can include
my __setitem__.precondition within the main IProperty
interface, and make that subclass from IContainer
instead of Interface. This works for me, because I'm
not going to want Property objects to contain other
Property objects, but I really haven't been able to
track down why it should work for the message board,
but not for my classes / interfaces. The errors I was
getting before my work around seemed to be indicating
that it wasn't a container, although I was subclassing
BTreeContainer, and implementing three interfaces (one
and Interface, one and IContained, and one
IContainer). Mostly this presented itself as Zope
complaining about using __len__ on the object. (As I
say, I have worked around this, and mention it mostly
in case it sheds any light on the issue below...)
My current problem, however, is proving harder to work
around. I want my Property objects to be able to
contain Images, and sets of attributes. (A typical set
of attributes would describe what is in the kitchen).
I have created interfaces IAttribSet(Interface),
IAttribSetContainer(IContainer) and
IAttribSetKitchen(IAttribSet); and classes AttribSet
(implements IAttribSet and IAttribSetContained) and
AttribSetKitchen (implements IAttribSetKitchen). I am
using IAttribSetContained to create a __parent__
ContainerTypesConstraint. I have wired up the kitchen
attrib set in .zcml files.
When I 'turn off' implementing IAttribSetContained, my
kitchen attrib set is working fine, in that I can add
it anywhere, and edit it. However, when I try to add a
condition saying where it can go (i.e. I only want it
to be within Property objects) it correctly only
appears as an Add-menu item within Property objects,
but on adding it, I get an error, saying
"AttribSetKitchen instance has no attribute
'__parent__'". My Property and PropertyFolder objects
are implemented as BTreeContainers.
I'm really quite stumped by this, so I would
appreciate any guidance that could be provided on
tracking down the source of the errors.
Thanks,
Jim
--- Lennart Regebro <regebro at gmail.com> wrote:
> On 6/22/05, Jim Vine <jim_a_vine at yahoo.co.uk> wrote:
> > I think I've convinced myself that the complexity
> of
> > my app takes it beyond method 1, but I'm strugling
> to
> > get my head around the implications of selecting
> > method 2 or 3. Am I right in thinking that either
> of
> > these will result in my building a "Product"?
>
> Yes.
>
> > If I
> > want to add extra feature to my product on the
> > development server and then port them to the live
> > server (with all the data on the live server being
> > left in tact), will selection of either of these
> > particularly help or hinder me in this?
>
> I don't know, because when I tried 2., it turned out
> to be quite
> complicated, and I never understood how to do it. So
> I did 3. And
> afterwards I have realized that even if you do
> understand how to do 2,
> the fact that you do most of your stuff in the
> restricted python
> scripts and dtml or ZPT, means that you have tons of
> limitations to go
> around.
>
> In addition to that, you can't easily use any proper
> editors to edit
> the code, which is very annoying.
>
> Method 2 (aka ZClasses) simply seem to offer exactly
> zero benefits,
> and loads of drawbacks.
>
> Also, as mentioned earlier, unless you want to build
> your application
> on top of one of the Zope2 content management
> systems around (CPS,
> Plone, Silva, ...) you probably want too use Zope3
> for your
> application development anyway. And then only method
> 3 (disk based
> development) is available.
>
> --
> Lennart Regebro, Nuxeo http://www.nuxeo.com/
> CPS Content Management
> http://www.cps-project.org/
> _______________________________________________
> Zope maillist - Zope at zope.org
> http://mail.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://mail.zope.org/mailman/listinfo/zope-announce
> http://mail.zope.org/mailman/listinfo/zope-dev )
>
___________________________________________________________
How much free photo storage do you get? Store your holiday
snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com
More information about the Zope
mailing list