@@ -73,7 +73,7 @@ class node. Any parts of other types are each stored in separate files
7373an exception, the original message is bounced back to the sender with the
7474explanatory message given in the exception.
7575
76- $Id: mailgw.py,v 1.39 2001-12-02 05:06:16 richard Exp $
76+ $Id: mailgw.py,v 1.40 2001-12-05 14:26:44 rochecompaan Exp $
7777'''
7878
7979
@@ -342,9 +342,26 @@ def handle_message(self, message):
342342Subject was: "%s"
343343''' % (key , message , subject )
344344 elif isinstance (proptype , hyperdb .Link ):
345- props [key ] = value .strip ()
345+ link = self .db .classes [proptype .classname ]
346+ propkey = link .labelprop (default_to_id = 1 )
347+ try :
348+ props [key ] = link .get (value .strip (), propkey )
349+ except :
350+ props [key ] = link .lookup (value .strip ())
346351 elif isinstance (proptype , hyperdb .Multilink ):
347- props [key ] = [x .strip () for x in value .split (',' )]
352+ link = self .db .classes [proptype .classname ]
353+ propkey = link .labelprop (default_to_id = 1 )
354+ l = [x .strip () for x in value .split (',' )]
355+ for item in l :
356+ try :
357+ v = link .get (item , propkey )
358+ except :
359+ v = link .lookup (item )
360+ if props .has_key (key ):
361+ props [key ].append (v )
362+ else :
363+ props [key ] = [v ]
364+
348365
349366 #
350367 # handle the users
@@ -459,20 +476,6 @@ def handle_message(self, message):
459476 # the newly created "msg" node is added to the "messages" property
460477 # for that item, and any new "file" nodes are added to the "files"
461478 # property for the item.
462- message_id = self .db .msg .create (author = author ,
463- recipients = recipients , date = date .Date ('.' ), summary = summary ,
464- content = content , files = files )
465- try :
466- messages = cl .get (nodeid , 'messages' )
467- except IndexError :
468- raise MailUsageError , '''
469- The node specified by the designator in the subject of your message ("%s")
470- does not exist.
471-
472- Subject was: "%s"
473- ''' % (nodeid , subject )
474- messages .append (message_id )
475- props ['messages' ] = messages
476479
477480 # if the message is currently 'unread' or 'resolved', then set
478481 # it to 'chatting'
@@ -490,22 +493,43 @@ def handle_message(self, message):
490493 props ['status' ] == resolved_id ):
491494 props ['status' ] = chatting_id
492495
493- # add nosy in arguments to issue's nosy list, don't replace
494- if props .has_key ('nosy' ):
495- n = {}
496- for nid in cl .get (nodeid , 'nosy' ):
497- n [nid ] = 1
498- for value in props ['nosy' ]:
499- if self .db .hasnode ('user' , value ):
500- nid = value
501- else :
502- try :
503- nid = self .db .user .lookup (value )
504- except :
505- continue
506- if n .has_key (nid ): continue
507- n [nid ] = 1
508- props ['nosy' ] = n .keys ()
496+ # add nosy in arguments to issue's nosy list
497+ if not props .has_key ('nosy' ): props ['nosy' ] = []
498+ n = {}
499+ for nid in cl .get (nodeid , 'nosy' ):
500+ n [nid ] = 1
501+ for value in props ['nosy' ]:
502+ if self .db .hasnode ('user' , value ):
503+ nid = value
504+ else :
505+ continue
506+ if n .has_key (nid ): continue
507+ n [nid ] = 1
508+ props ['nosy' ] = n .keys ()
509+ try :
510+ assignedto = self .db .user .lookup (props ['assignedto' ])
511+ if assignedto not in props ['nosy' ]:
512+ props ['nosy' ].append (assignedto )
513+ except :
514+ pass
515+
516+ change_note = cl .generateChangeNote (nodeid , props )
517+ content += change_note
518+
519+ message_id = self .db .msg .create (author = author ,
520+ recipients = recipients , date = date .Date ('.' ), summary = summary ,
521+ content = content , files = files )
522+ try :
523+ messages = cl .get (nodeid , 'messages' )
524+ except IndexError :
525+ raise MailUsageError , '''
526+ The node specified by the designator in the subject of your message ("%s")
527+ does not exist.
528+
529+ Subject was: "%s"
530+ ''' % (nodeid , subject )
531+ messages .append (message_id )
532+ props ['messages' ] = messages
509533
510534 # now apply the changes
511535 try :
@@ -542,9 +566,22 @@ def handle_message(self, message):
542566
543567 # pre-load the messages list and nosy list
544568 props ['messages' ] = [message_id ]
545- props ['nosy' ] = props .get ('nosy' , []) + recipients
546- props ['nosy' ].append (author )
547- props ['nosy' ].sort ()
569+ nosy = props .get ('nosy' , [])
570+ n = {}
571+ for value in nosy :
572+ if self .db .hasnode ('user' , value ):
573+ nid = value
574+ else :
575+ try :
576+ nid = self .db .user .lookup (value )
577+ except :
578+ continue
579+ if n .has_key (nid ): continue
580+ n [nid ] = 1
581+ props ['nosy' ] = n .keys () + recipients
582+ if not n .has_key (author ):
583+ props ['nosy' ].append (author )
584+ n [author ] = 1
548585
549586 # and attempt to create the new node
550587 try :
@@ -598,6 +635,20 @@ def parseContent(content, blank_line=re.compile(r'[\r\n]+\s*[\r\n]+'),
598635
599636#
600637# $Log: not supported by cvs2svn $
638+ # Revision 1.39 2001/12/02 05:06:16 richard
639+ # . We now use weakrefs in the Classes to keep the database reference, so
640+ # the close() method on the database is no longer needed.
641+ # I bumped the minimum python requirement up to 2.1 accordingly.
642+ # . #487480 ] roundup-server
643+ # . #487476 ] INSTALL.txt
644+ #
645+ # I also cleaned up the change message / post-edit stuff in the cgi client.
646+ # There's now a clearly marked "TODO: append the change note" where I believe
647+ # the change note should be added there. The "changes" list will obviously
648+ # have to be modified to be a dict of the changes, or somesuch.
649+ #
650+ # More testing needed.
651+ #
601652# Revision 1.38 2001/12/01 07:17:50 richard
602653# . We now have basic transaction support! Information is only written to
603654# the database when the commit() method is called. Only the anydbm
0 commit comments