comparison roundup/roundupdb.py @ 2518:cf17ba0a72f9

list IssueClass property names for message extraction tool
author Alexander Smishlajev <a1s@users.sourceforge.net>
date Fri, 02 Jul 2004 08:27:56 +0000
parents 091711fb2f8c
children f313ea652571
comparison
equal deleted inserted replaced
2517:9260152ad143 2518:cf17ba0a72f9
12 # BIZAR SOFTWARE PTY LTD SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, 12 # BIZAR SOFTWARE PTY LTD SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
17 # 17 #
18 # $Id: roundupdb.py,v 1.109 2004-07-02 05:22:08 richard Exp $ 18 # $Id: roundupdb.py,v 1.110 2004-07-02 08:27:56 a1s Exp $
19 19
20 """Extending hyperdb with types specific to issue-tracking. 20 """Extending hyperdb with types specific to issue-tracking.
21 """ 21 """
22 __docformat__ = 'restructuredtext' 22 __docformat__ = 'restructuredtext'
23 23
51 """ 51 """
52 userid = self.getuid() 52 userid = self.getuid()
53 try: 53 try:
54 timezone = int(self.user.get(userid, 'timezone')) 54 timezone = int(self.user.get(userid, 'timezone'))
55 except (KeyError, ValueError, TypeError): 55 except (KeyError, ValueError, TypeError):
56 # If there is no class 'user' or current user doesn't have timezone 56 # If there is no class 'user' or current user doesn't have timezone
57 # property or that property is not numeric assume he/she lives in 57 # property or that property is not numeric assume he/she lives in
58 # Greenwich :) 58 # Greenwich :)
59 timezone = getattr(self.config, 'DEFAULT_TIMEZONE', 0) 59 timezone = getattr(self.config, 'DEFAULT_TIMEZONE', 0)
60 return timezone 60 return timezone
61 61
62 def confirm_registration(self, otk): 62 def confirm_registration(self, otk):
76 # tag new user creation with 'admin' 76 # tag new user creation with 'admin'
77 self.journaltag = 'admin' 77 self.journaltag = 'admin'
78 78
79 # create the new user 79 # create the new user
80 cl = self.user 80 cl = self.user
81 81
82 props['roles'] = self.config.NEW_WEB_USER_ROLES 82 props['roles'] = self.config.NEW_WEB_USER_ROLES
83 userid = cl.create(**props) 83 userid = cl.create(**props)
84 # clear the props from the otk database 84 # clear the props from the otk database
85 self.getOTKManager().destroy(otk) 85 self.getOTKManager().destroy(otk)
86 self.commit() 86 self.commit()
87 87
88 return userid 88 return userid
89 89
90 90
91 class DetectorError(RuntimeError): 91 class DetectorError(RuntimeError):
92 """ Raised by detectors that want to indicate that something's amiss 92 """ Raised by detectors that want to indicate that something's amiss
105 - files = hyperdb.Multilink("file") 105 - files = hyperdb.Multilink("file")
106 - nosy = hyperdb.Multilink("user") 106 - nosy = hyperdb.Multilink("user")
107 - superseder = hyperdb.Multilink(classname) 107 - superseder = hyperdb.Multilink(classname)
108 """ 108 """
109 109
110 # The tuple below does not affect the class definition.
111 # It just lists all names of all issue properties
112 # marked for message extraction tool.
113 #
114 # XXX is there better way to get property names into message catalog??
115 #
116 # Note that this list also includes properties
117 # defined in the classic template:
118 # assignedto, topic, priority, status.
119 (''"title", ''"messages", ''"files", ''"nosy", ''"superseder",
120 ''"assignedto", ''"topic", ''"priority", ''"status")
121
110 # New methods: 122 # New methods:
111 def addmessage(self, nodeid, summary, text): 123 def addmessage(self, nodeid, summary, text):
112 """Add a message to an issue's mail spool. 124 """Add a message to an issue's mail spool.
113 125
114 A new "msg" node is constructed using the current date, the user that 126 A new "msg" node is constructed using the current date, the user that
125 from_address=None, cc=[], bcc=[]): 137 from_address=None, cc=[], bcc=[]):
126 """Send a message to the members of an issue's nosy list. 138 """Send a message to the members of an issue's nosy list.
127 139
128 The message is sent only to users on the nosy list who are not 140 The message is sent only to users on the nosy list who are not
129 already on the "recipients" list for the message. 141 already on the "recipients" list for the message.
130 142
131 These users are then added to the message's "recipients" list. 143 These users are then added to the message's "recipients" list.
132 144
133 If 'msgid' is None, the message gets sent only to the nosy 145 If 'msgid' is None, the message gets sent only to the nosy
134 list, and it's called a 'System Message'. 146 list, and it's called a 'System Message'.
135 147
142 list. These recipients will not be included in the To: or Cc: 154 list. These recipients will not be included in the To: or Cc:
143 address lists. 155 address lists.
144 """ 156 """
145 authid = self.db.msg.safeget(msgid, 'author') 157 authid = self.db.msg.safeget(msgid, 'author')
146 recipients = self.db.msg.safeget(msgid, 'recipients', []) 158 recipients = self.db.msg.safeget(msgid, 'recipients', [])
147 159
148 sendto = [] 160 sendto = []
149 bcc_sendto = [] 161 bcc_sendto = []
150 seen_message = {} 162 seen_message = {}
151 for recipient in recipients: 163 for recipient in recipients:
152 seen_message[recipient] = 1 164 seen_message[recipient] = 1
169 # anonymous 181 # anonymous
170 if (good_recipient(authid) and 182 if (good_recipient(authid) and
171 (self.db.config.MESSAGES_TO_AUTHOR == 'yes' or 183 (self.db.config.MESSAGES_TO_AUTHOR == 'yes' or
172 (self.db.config.MESSAGES_TO_AUTHOR == 'new' and not oldvalues))): 184 (self.db.config.MESSAGES_TO_AUTHOR == 'new' and not oldvalues))):
173 add_recipient(authid, sendto) 185 add_recipient(authid, sendto)
174 186
175 if authid: 187 if authid:
176 seen_message[authid] = 1 188 seen_message[authid] = 1
177 189
178 # now deal with the nosy and cc people who weren't recipients. 190 # now deal with the nosy and cc people who weren't recipients.
179 for userid in cc + self.get(nodeid, whichnosy): 191 for userid in cc + self.get(nodeid, whichnosy):
180 if good_recipient(userid): 192 if good_recipient(userid):
181 add_recipient(userid, sendto) 193 add_recipient(userid, sendto)
182 194
183 # now deal with bcc people. 195 # now deal with bcc people.
184 for userid in bcc: 196 for userid in bcc:
185 if good_recipient(userid): 197 if good_recipient(userid):
186 add_recipient(userid, bcc_sendto) 198 add_recipient(userid, bcc_sendto)
207 recipients, with the note appended. 219 recipients, with the note appended.
208 ''' 220 '''
209 users = self.db.user 221 users = self.db.user
210 messages = self.db.msg 222 messages = self.db.msg
211 files = self.db.file 223 files = self.db.file
212 224
213 inreplyto = messages.safeget(msgid, 'inreplyto') 225 inreplyto = messages.safeget(msgid, 'inreplyto')
214 messageid = messages.safeget(msgid, 'messageid') 226 messageid = messages.safeget(msgid, 'messageid')
215 227
216 # make up a messageid if there isn't one (web edit) 228 # make up a messageid if there isn't one (web edit)
217 if not messageid: 229 if not messageid:
349 def email_signature(self, nodeid, msgid): 361 def email_signature(self, nodeid, msgid):
350 ''' Add a signature to the e-mail with some useful information 362 ''' Add a signature to the e-mail with some useful information
351 ''' 363 '''
352 # simplistic check to see if the url is valid, 364 # simplistic check to see if the url is valid,
353 # then append a trailing slash if it is missing 365 # then append a trailing slash if it is missing
354 base = self.db.config.TRACKER_WEB 366 base = self.db.config.TRACKER_WEB
355 if (not isinstance(base , type('')) or 367 if (not isinstance(base , type('')) or
356 not (base.startswith('http://') or base.startswith('https://'))): 368 not (base.startswith('http://') or base.startswith('https://'))):
357 web = "Configuration Error: TRACKER_WEB isn't a " \ 369 web = "Configuration Error: TRACKER_WEB isn't a " \
358 "fully-qualified URL" 370 "fully-qualified URL"
359 else: 371 else:

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