[Zope-dev] Re:[Zope] help with magic method "__of__"

Butch Landingin butchland@yahoo.com
Sun, 11 Apr 1999 17:50:27 -0700 (PDT)


Hi,
I've been playing around with Confera for about 4 weeks now -- but I'm not
the original developer nor am I an employee of Digital Creations (hint!hint!) 
so <YMMV>take the following with a grain of salt</YMMV>.

On April 11, 1999 "Karl & Mel" <llwo@dbtech.net> wrote:
>I know that Confera is not supported, but I am using it as a base for an =
>extended version that would allow messages to be moved, reordered, =
>copied, paseted, etc.  In otherwords turn Messages into folderish? =
>containerish? objects.  I don't want to give up the indexing and =
>searching though.  Which leads me to believe that I need to override the =
>'setItem' and '__getitem__' maybe?

I think you'd probably need to add methods in the Message/Topic classes to remove a 
child message (i.e. id in the intSet self.ids) (this would be to implement a <cut> function) and
reattaching itself to another message or topic (to implement a paste function)

You can *probably*(just a guess, I haven't fiddled around too much with this) use the setitem to
paste messages to another message but it does'nt have to do the indexing because it would already
have been indexed when it was added, but it also has to handle reorganizing the thread field
of the message you are moving so that these reflect the new paths (note that if the message
being moved has children (i.e. replies), their thread fields also have to be updated and so on
recursively)

I don't know why you'd have to modify __getitem__ though.

In the cut function, you can probably base it on the delItem function (just take out the 
unindexing and delete object parts)

As for the other functions (reodering,etc.), I don't have enough info to suggest anything...

>
>Anyway
>
>As I've been reading the code over and over and over (two weeks now) and =
>have thrown out three attempts.  I keep seeing things like
>
>self.data[id].__of__(self)
>msg=3Dmsg.__of__(self)
>r=3Dmap(lambda x, p=3Dself: x.__of__(p), r)
>
>How does the magic method '__of__()'  work?
>
>Also how does intSet{} work?
>
>ta for any info.

Grab the code in the Zope CVS area. If you're on Windows, theres a nice gui
front end called WinCvs (http://www.wincvs.org) that allows you to
mirror the entire Zope source distribution on your local drive. 

The reason for this is that the definitions of IntSet and the
magic __of__  methods are defined in the c modules which are included
in the source distribution (see Acquisition.c and intSet.c).

AFAIK, obj.__of__(self) attaches your object (obj) to the Acquisition hierarchy 
(of which the self object is already a part of)
so that it becomes accessible as a URL in Zope
...In Zopish, this is known as '*wrapping* the
object into an acquisition wrapper'...

If this is not as clear as it should be
it's because I'm not that exactly sure of it myself :(
Maybe somebody from DC or the original Confera developer can confirm this...


HTH.

Butch Landingin

P.S. 
If you do get around to implement those things -- maybe you can send me some of
the source code to see. I'm trying to finish up 0.1 version of a Zope Product
that's based on Confera that implements a SlashDot-like website and I might be
able to use some of the code you have <ain't Open Source great? ;)>.

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com