comparison roundup/cgi_client.py @ 188:1536be43d2fa

Roundupdb now appends "mailing list" information to its messages... ...which include the e-mail address and web interface address. Templates may override this in their db classes to include specific information (support instructions, etc).
author Richard Jones <richard@users.sourceforge.net>
date Thu, 02 Aug 2001 06:38:17 +0000
parents 61355a9483f4
children d45384bc6420
comparison
equal deleted inserted replaced
187:0384459b2486 188:1536be43d2fa
1 # $Id: cgi_client.py,v 1.16 2001-08-02 05:55:25 richard Exp $ 1 # $Id: cgi_client.py,v 1.17 2001-08-02 06:38:17 richard Exp $
2 2
3 import os, cgi, pprint, StringIO, urlparse, re, traceback, mimetypes 3 import os, cgi, pprint, StringIO, urlparse, re, traceback, mimetypes
4 4
5 import roundupdb, htmltemplate, date 5 import roundupdb, htmltemplate, date
6 6
227 if value != cl.get(self.nodeid, key): 227 if value != cl.get(self.nodeid, key):
228 changed.append(key) 228 changed.append(key)
229 props[key] = value 229 props[key] = value
230 cl.set(self.nodeid, **props) 230 cl.set(self.nodeid, **props)
231 231
232 self._post_editnode(self.nodeid) 232 self._post_editnode(self.nodeid, changed)
233 # and some nice feedback for the user 233 # and some nice feedback for the user
234 message = '%s edited ok'%', '.join(changed) 234 message = '%s edited ok'%', '.join(changed)
235 except: 235 except:
236 s = StringIO.StringIO() 236 s = StringIO.StringIO()
237 traceback.print_exc(None, s) 237 traceback.print_exc(None, s)
318 l.sort() 318 l.sort()
319 value = l 319 value = l
320 props[key] = value 320 props[key] = value
321 return cl.create(**props) 321 return cl.create(**props)
322 322
323 def _post_editnode(self, nid): 323 def _post_editnode(self, nid, changes=None):
324 ''' do the linking and message sending part of the node creation 324 ''' do the linking and message sending part of the node creation
325 ''' 325 '''
326 cn = self.classname 326 cn = self.classname
327 cl = self.db.classes[cn] 327 cl = self.db.classes[cn]
328 # link if necessary 328 # link if necessary
372 summary = re.split(r'\n\r?', note)[0] 372 summary = re.split(r'\n\r?', note)[0]
373 else: 373 else:
374 summary = note 374 summary = note
375 m = ['%s\n'%note] 375 m = ['%s\n'%note]
376 else: 376 else:
377 summary = 'This %s has been created through the web.\n'%cn 377 summary = 'This %s has been edited through the web.\n'%cn
378 m = [summary] 378 m = [summary]
379 m.append('\n-------\n')
380 379
381 # generate an edit message - nosyreactor will send it 380 # generate an edit message - nosyreactor will send it
381 first = 1
382 for name, prop in props.items(): 382 for name, prop in props.items():
383 if changes is not None and name not in changes: continue
384 if first:
385 m.append('\n-------')
386 first = 0
383 value = cl.get(nid, name, None) 387 value = cl.get(nid, name, None)
384 if prop.isLinkType: 388 if prop.isLinkType:
385 link = self.db.classes[prop.classname] 389 link = self.db.classes[prop.classname]
386 key = link.getkey() 390 key = link.labelprop(default_to_id=1)
387 if value is not None and key: 391 if value is not None and key:
388 value = link.get(value, key) 392 value = link.get(value, key)
389 else: 393 else:
390 value = '-' 394 value = '-'
391 elif prop.isMultilinkType: 395 elif prop.isMultilinkType:
392 if value is None: value = [] 396 if value is None: value = []
393 l = [] 397 l = []
394 link = self.db.classes[prop.classname] 398 link = self.db.classes[prop.classname]
399 key = link.labelprop(default_to_id=1)
395 for entry in value: 400 for entry in value:
396 key = link.getkey()
397 if key: 401 if key:
398 l.append(link.get(entry, link.getkey())) 402 l.append(link.get(entry, link.getkey()))
399 else: 403 else:
400 l.append(entry) 404 l.append(entry)
401 value = ', '.join(l) 405 value = ', '.join(l)
402 m.append('%s: %s'%(name, value)) 406 m.append('%s: %s'%(name, value))
403 407
404 # now create the message 408 # now create the message
405 content = '\n'.join(m) 409 content = '\n'.join(m)
406 nosy.remove(self.getuid())
407 message_id = self.db.msg.create(author=self.getuid(), 410 message_id = self.db.msg.create(author=self.getuid(),
408 recipients=nosy, date=date.Date('.'), summary=summary, 411 recipients=[], date=date.Date('.'), summary=summary,
409 content=content) 412 content=content)
410 messages = cl.get(nid, 'messages') 413 messages = cl.get(nid, 'messages')
411 messages.append(message_id) 414 messages.append(message_id)
412 props = {'messages': messages} 415 props = {'messages': messages}
413 cl.set(nid, **props) 416 cl.set(nid, **props)
534 def __del__(self): 537 def __del__(self):
535 self.db.close() 538 self.db.close()
536 539
537 # 540 #
538 # $Log: not supported by cvs2svn $ 541 # $Log: not supported by cvs2svn $
542 # Revision 1.16 2001/08/02 05:55:25 richard
543 # Web edit messages aren't sent to the person who did the edit any more. No
544 # message is generated if they are the only person on the nosy list.
545 #
539 # Revision 1.15 2001/08/02 00:34:10 richard 546 # Revision 1.15 2001/08/02 00:34:10 richard
540 # bleah syntax error 547 # bleah syntax error
541 # 548 #
542 # Revision 1.14 2001/08/02 00:26:16 richard 549 # Revision 1.14 2001/08/02 00:26:16 richard
543 # Changed the order of the information in the message generated by web edits. 550 # Changed the order of the information in the message generated by web edits.

Roundup Issue Tracker: http://roundup-tracker.org/