Changeset 450
- Timestamp:
- 09/11/08 16:25:25 (5 years ago)
- Location:
- trunk/trac-hacks/announcerplugin
- Files:
-
- 5 edited
-
announcerplugin/api.py (modified) (3 diffs)
-
announcerplugin/distributors/email_distributor.py (modified) (6 diffs)
-
announcerplugin/subscribers/ticket_groups.py (modified) (2 diffs)
-
announcerplugin/subscribers/watchers.py (modified) (6 diffs)
-
setup.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/trac-hacks/announcerplugin/announcerplugin/api.py
r175 r450 2 2 from trac.util.compat import set 3 3 from trac.db import Table, Column, Index 4 from trac.db import DatabaseManager 4 5 from trac.env import IEnvironmentSetupParticipant 5 6 import time … … 305 306 def _upgrade_db(self, db): 306 307 try: 307 from trac.db import DatabaseManager308 308 db_backend, _ = DatabaseManager(self.env)._get_connector() 309 309 … … 341 341 for sp in self.subscribers: 342 342 categories = sp.get_subscription_categories(evt.realm) 343 if ('*' in categories) or (evt.category in categories): 344 supported_subscribers.append(sp) 343 if categories: 344 if ('*' in categories) or (evt.category in categories): 345 supported_subscribers.append(sp) 345 346 346 347 self.log.debug( -
trunk/trac-hacks/announcerplugin/announcerplugin/distributors/email_distributor.py
r340 r450 12 12 from email.MIMEMultipart import MIMEMultipart 13 13 from email.MIMEText import MIMEText 14 from email.Utils import formatdate 15 from email.header import Header 14 16 import time, Queue, threading, smtplib 15 17 … … 206 208 AND authenticated=%s 207 209 AND name=%s 208 """, (sid, authenticated, 'announcer_email_format_%s' % realm))210 """, (sid, int(authenticated), 'announcer_email_format_%s' % realm)) 209 211 210 212 result = cursor.fetchone() … … 223 225 subject = formatter.format_subject(transport, event.realm, format, event) 224 226 227 charset = self.env.config.get('trac', 'default_charset') or 'utf-8' 225 228 alternate_format = formatter.get_format_alternative(transport, event.realm, format) 226 229 if alternate_format: … … 244 247 rootMessage['X-Announcement-%s' % key.capitalize()] = str(provided_headers[key]) 245 248 246 rootMessage['Subject'] = subject 249 rootMessage['Date'] = formatdate() 250 rootMessage['Subject'] = Header(subject, charset) 247 251 rootMessage['From'] = self.smtp_from 248 252 if to: … … 260 264 261 265 if alternate_output: 262 msgText = MIMEText(alternate_output, 'html' in alternate_format and 'html' or 'plain' )266 msgText = MIMEText(alternate_output, 'html' in alternate_format and 'html' or 'plain', charset) 263 267 parentMessage.attach(msgText) 264 268 265 msgText = MIMEText(output, 'html' in format and 'html' or 'plain' )269 msgText = MIMEText(output, 'html' in format and 'html' or 'plain', charset) 266 270 parentMessage.attach(msgText) 267 271 268 272 start = time.time() 269 273 270 274 package = (self.smtp_from, [x[2] for x in recipients if x], rootMessage.as_string() ) 271 275 if self.use_threaded_delivery: … … 280 284 smtp = smtplib.SMTP() 281 285 smtp.connect(self.smtp_server) 286 if self.use_tls: 287 smtp.ehlo() 288 smtp.starttls() 289 smtp.ehlo() 282 290 if self.smtp_user: 283 291 smtp.login(self.smtp_user, self.smtp_password) -
trunk/trac-hacks/announcerplugin/announcerplugin/subscribers/ticket_groups.py
r175 r450 21 21 def get_subscription_categories(self, realm): 22 22 if realm == "ticket": 23 yield 'changed'24 yield 'created'25 yield 'attachment added'23 return('changed', 'created', 'attachment added') 24 else: 25 () 26 26 27 27 def get_subscriptions_for_event(self, event): … … 50 50 cursor.execute(""" 51 51 SELECT sid, authenticated 52 FROM session_attribute 53 ANDname=%s52 FROM session_attribute 53 WHERE name=%s 54 54 AND value=%s 55 55 """, ('announcer_joinable_group_' + group, "1")) -
trunk/trac-hacks/announcerplugin/announcerplugin/subscribers/watchers.py
r175 r450 77 77 AND category=%s 78 78 AND rule=%s 79 """, (sid, authenticated and 1 or 0, 'watcher', realm, '*', resource))79 """, (sid, int(authenticated), 'watcher', realm, '*', str(resource))) 80 80 81 81 result = cursor.fetchone() … … 103 103 %s, %s) 104 104 """, ( 105 sid, authenticated,105 sid, int(authenticated), 106 106 'watcher', realm, '*', 107 107 resource, 'email' … … 127 127 AND category=%s 128 128 AND rule=%s 129 """, (sid, authenticated, 'watcher', realm, '*', resource))129 """, (sid, int(authenticated), 'watcher', realm, '*', str(resource))) 130 130 131 131 if not use_db: … … 198 198 AND realm=%s 199 199 AND rule=%s 200 """, ('watcher', 'wiki', page.name))200 """, ('watcher', 'wiki', str(page.name))) 201 201 202 202 db.commit() … … 224 224 AND realm=%s 225 225 AND rule=%s 226 """, ('watcher', 'ticket', ticket.id))226 """, ('watcher', 'ticket', str(ticket.id))) 227 227 228 228 db.commit() … … 249 249 AND category=%s 250 250 AND rule=%s 251 """, ('watcher', event.realm, '*', self._get_target_identifier(event.realm, event.target))) 251 """, ('watcher', event.realm, '*', 252 str(self._get_target_identifier(event.realm, 253 event.target)))) 252 254 253 255 for transport, sid, authenticated in cursor.fetchall(): -
trunk/trac-hacks/announcerplugin/setup.py
r175 r450 28 28 # ---------------------------------------------------------------------------- 29 29 30 # Maintained by doki_pen <doki_pen@doki-pen.org> 31 30 32 from setuptools import find_packages, setup 31 33
Note: See TracChangeset
for help on using the changeset viewer.
