1- # $Id: cgi_client.py,v 1.15 2001-08-02 00:34:10 richard Exp $
1+ # $Id: cgi_client.py,v 1.16 2001-08-02 05:55:25 richard Exp $
22
33import os , cgi , pprint , StringIO , urlparse , re , traceback , mimetypes
44
@@ -21,6 +21,9 @@ def __init__(self, out, db, env, user):
2121 self .headers_done = 0
2222 self .debug = 0
2323
24+ def getuid (self ):
25+ return self .db .user .lookup (self .user )
26+
2427 def header (self , headers = {'Content-Type' :'text/html' }):
2528 if not headers .has_key ('Content-Type' ):
2629 headers ['Content-Type' ] = 'text/html'
@@ -344,10 +347,21 @@ def _post_editnode(self, nid):
344347 link = self .db .classes [link ]
345348 link .set (nodeid , ** {property : nid })
346349
347- # if this item has messages,
348- if (cl .getprops ().has_key ('messages' ) and
349- cl .getprops ()['messages' ].isMultilinkType and
350- cl .getprops ()['messages' ].classname == 'msg' ):
350+ # see if we want to send a message to the nosy list...
351+ props = cl .getprops ()
352+ # don't do the message thing if there's no nosy list, or the editor
353+ # of the node is the only person on the nosy list - they're already
354+ # aware of the change.
355+ nosy = 0
356+ if props .has_key ('nosy' ):
357+ nosy = cl .get (nid , 'nosy' )
358+ uid = self .getuid ()
359+ if len (nosy ) == 1 and uid in nosy :
360+ nosy = 0
361+ if (nosy and props .has_key ('messages' ) and
362+ props ['messages' ].isMultilinkType and
363+ props ['messages' ].classname == 'msg' ):
364+
351365 # handle the note
352366 note = None
353367 if self .form .has_key ('__note' ):
@@ -365,8 +379,8 @@ def _post_editnode(self, nid):
365379 m .append ('\n -------\n ' )
366380
367381 # generate an edit message - nosyreactor will send it
368- for name , prop in cl . getprops () .items ():
369- value = cl .get (nid , name )
382+ for name , prop in props .items ():
383+ value = cl .get (nid , name , None )
370384 if prop .isLinkType :
371385 link = self .db .classes [prop .classname ]
372386 key = link .getkey ()
@@ -375,6 +389,7 @@ def _post_editnode(self, nid):
375389 else :
376390 value = '-'
377391 elif prop .isMultilinkType :
392+ if value is None : value = []
378393 l = []
379394 link = self .db .classes [prop .classname ]
380395 for entry in value :
@@ -388,8 +403,10 @@ def _post_editnode(self, nid):
388403
389404 # now create the message
390405 content = '\n ' .join (m )
391- message_id = self .db .msg .create (author = '1' , recipients = [],
392- date = date .Date ('.' ), summary = summary , content = content )
406+ nosy .remove (self .getuid ())
407+ message_id = self .db .msg .create (author = self .getuid (),
408+ recipients = nosy , date = date .Date ('.' ), summary = summary ,
409+ content = content )
393410 messages = cl .get (nid , 'messages' )
394411 messages .append (message_id )
395412 props = {'messages' : messages }
@@ -519,6 +536,9 @@ def __del__(self):
519536
520537#
521538# $Log: not supported by cvs2svn $
539+ # Revision 1.15 2001/08/02 00:34:10 richard
540+ # bleah syntax error
541+ #
522542# Revision 1.14 2001/08/02 00:26:16 richard
523543# Changed the order of the information in the message generated by web edits.
524544#
0 commit comments