[Twisted-Python] Generic hierarchy interface

Glyph Lefkowitz glyph at twistedmatrix.com
Tue Jun 18 03:16:45 EDT 2002

From: Jp Calderone <exarkun at meson.dyndns.org>
Subject: [Twisted-Python] Generic hierarchy interface
Date: Mon, 17 Jun 2002 17:04:32 -0400 (EDT)

> Its time has come.

I have to agree, given that I recently deduced the need for, then spent some
time working on a similar concept.  It's also extremely hard to work on.

> The need is pretty clear, partially for blog/news and a lot for Reality, and
> I'm sure for a lot of other things I'm not aware of.  Basically, what seems
> to be needed is an interface that allows for a protocol-defined hierarchy to
> protocol-specific data, organised based on protocol-specific meta-data.

... and aggregation within a protocol-independent hierarchy too, I would say.

> For example, consider email.  The protocol-specific hierarchy describes
> message threads (which you are all hopefully familiar with).  The
> meta-data is a portion of the xheaders ("References" and "In-Reply-To" in
> particular), and the data is the message body.

Interesting example.  I always felt the obvious collection interface to e-mail
would be the server/domain/user/mailbox hierarchy; groups are organized
differently (and there would probably be different interfaces for organization
by thread and organization by sender, let's say)

> A Reality example: "reality://server/Sol/Earth/Kansas/Smallville/Clark_Kent"


> I'm a little out of my element, so I hope this has been at least
> somewhat coherent ;)   Anyone have comments, or notice and horrible flaws,
> or just see a plain better way to go about it?

Well, this sort of design is right up my alley.  I've implemented similar
(though less general) systems on many occasions.  One might even say that the
essence of Twisted itself is to be an informal system of this type.  For that
reason, I'd really like to see a formal interface of what a "TwistedObject"
would be.

The problem with this particular, extremely general, application of an
"abstract hierarchy interface" is that it's not quite as abstract as we'd like
to think.  There are many problems that arise -- for example, you list the
relationship of "sibling", which most hierarchy interfaces do not support.
Python itself is a hierarchy interface, after all.  The __getitem__ and
__getattr__ interfaces implement identical hierarchies.

The key problems at this point, I think, are the notion of asynchronous access,
and ensuring homogeneity.  twisted.python.roots technically addresses one of
those problems, and could easily be modified to support the other, but it seems
horribly ugly to me for some reason that I don't quite understand.

Do you have any other ideas regarding a generic hierarchy interface?

 |    <`'>    |  Glyph Lefkowitz: Traveling Sorcerer   |
 |   < _/ >   |  Lead Developer,  the Twisted project  |
 |  < ___/ >  |      http://www.twistedmatrix.com      |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20020618/52056371/attachment.pgp 

More information about the Twisted-Python mailing list