[Zope-dev] Re:[Zope] help with magic method "__of__"
Karl & Mel
llwo@dbtech.net
Mon, 12 Apr 1999 07:05:56 -0500
Thanks for the info. Kinda what I thought after staring at it some more.
See below for what I came up with over the weekend. I think it is pretty
sound and will test it today.
class Topic
...
...<original stuff>
...
def manage_copy(self, ids[], paste_id='', REQUEST=None):
"""A mangement interface for copying messages.
Scenario:
Topic
Msg-1 *ids
Msg-3
Msg-4 *ids
Msg-5
Msg-2 *paste_id
Msg-6
Result of Copy:
Topic
Msg-1
Msg-3
Msg-4
Msg-5
Msg-2
Copy-of-Msg-1
Copy-of-Msg-3
Copy-of-Msg-4
Copy-of-Msg-5
Msg-6
Notice that mesages selected in ids become branches.
This is the intended result.
There will also be a complimentary manage_move() that will copy
then delete the mesages listed in ids.
"""
data=self.data
ids=map(atoi, ids)
for id in ids:
# not sure about namespace of root_object so set this inside
loop
if paste_id != '':
paste_id=atoi(paste_id)
root_object=data[paste_id]
else:
root_object=self
copyItems(id, root_object, ids)
def copyItems(self, id, root_object, branches)
data=self.data
item=data[id]
# Start copy
title=item.title
author=item.author
body=item.body
email=item.email
notify=item.notify
file=item.file
submit=' Add '
# Make new message in root_object
root_object.addMessage(title, author, body, email, notify, file,
submit)
for id in item.ids:
if id not in branches:
self.copyItems(id, item, branches)
I also remembered about the CVS thing after I sent the message. That was a
big help in deciding how to do the copy. I couldn't just move a message
becaues of the line that says msg=msg.__of__(self). The original ID is
bound in the namespace to it's parent so easy enough to just self.addMessage
to create a new id and binding in the new spot, then delete the old
messages. Not done yet, but the paste_id is selected by a modified
Topic_manage_messages.dtml
<INPUT TYPE="CHECKBOX" NAME="ids:list" VALUE="<!--#var id-->">
<INPUT TYPE="RADIO" NAME="paste_id" VALUE="<!--#var id-->">
at both places where it appears. Also still need to do some error checking
so that a paste_id in the ids.sub_id (mangle) will raise an idiot error.
I am psyched that I grok ;-) now. Zope rulz
I don't quite know how to produce a patch but I will post all of the changes
when I have them complete and working. Should be a couple of days.
Karl
----- Original Message -----
From: Butch Landingin <butchland@yahoo.com>
> 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)
>
>
> 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...