- Timestamp:
- 10/17/07 04:57:00 (1 year ago)
- Location:
- branches/3.0
- Files:
-
- 1 added
- 2 removed
- 3 modified
-
setup.py (modified) (1 diff)
-
turbomail/__init__.py (modified) (1 diff)
-
turbomail/api.py (added)
-
turbomail/control.py (modified) (6 diffs)
-
turbomail/extensions/_base.py (deleted)
-
turbomail/extensions/security.py (deleted)
Legend:
- Unmodified
- Added
- Removed
-
branches/3.0/setup.py
r33 r37 48 48 ], 49 49 'turbomail.managers': [ 50 "demand = turbomail.managers.demand :DemandManager"51 "polling = turbomail.managers.polling:PollingManager"50 "demand = turbomail.managers.demand" 51 # "polling = turbomail.managers.polling" 52 52 ], 53 53 'turbomail.providers': [ 54 "smtp = turbomail.providers.smtp:SMTPProvider", 55 "sendmail = turbomail.providers.sendmail:SendmailProvider" 54 "smtp = turbomail.providers.smtp", 55 # "sendmail = turbomail.providers.sendmail" 56 # "disk = turbomail.providers.disk", 57 # "debug = turbomail.providers.debug" 56 58 ], 57 59 'turbomail.extensions': [ 58 "security = turbomail.extensions:SecurityExtension" 60 # "smime = turbomail.extensions.smime", 61 # "gpg = turbomail.extensions.gpg", 59 62 ] 60 63 } -
branches/3.0/turbomail/__init__.py
r33 r37 16 16 copyright as __copyright__ 17 17 18 __import__('pkg_resources').declare_namespace(__name__) 18 from turbomail.message import Message 19 19 20 20 21 import logging 22 log = logging.getLogger("turbomail") 21 __all__ = ['exceptions', 'extensions', 'managers', 'providers', 'release', 'manager', 'provider', 'config', 'Message'] 23 22 24 23 25 __all__ = ['exceptions', 'extensions', 'managers', 'providers', 'release', 'turbogears'] 24 manager = None 25 provider = None 26 config = {} -
branches/3.0/turbomail/control.py
r33 r37 1 1 # encoding: utf-8 2 2 3 """TurboGears extension startup and shutdown interface.""" 3 """TurboGears extension startup and shutdown interface. 4 5 TurboGears will automatically start and stop TurboMail if you configure 6 your application with `mail.on = True`. To start and stop TurboMail 7 in your own applications:: 8 9 import turbomail 10 turbomail.interface.start() 11 12 message = turbomail.Message(...) 13 turbomail.send(message) 14 15 turbomail.interface.stop() 16 17 TurboMail will, by default, immediately delete any messages remaining in 18 the queue and wait on any in-progress deliveries. To block execution and 19 allow the queue to empty, pass `blocking=True` as an argument to `stop`. 20 """ 4 21 5 22 import logging … … 12 29 13 30 class ControlClass(object): 31 """Control TurboMail startup and shutdown. 32 33 Dynamically discovers the presence of TurboGears, creating appropriate aliases for 34 TurboGears extension startup and shutdown.""" 35 14 36 def __init__(self): 15 37 self.running = False … … 18 40 import turbogears 19 41 except ImportError: 20 self.config = dict()42 turbomail.config = dict() 21 43 else: 22 self.config = turbogears.config 44 turbomail.config = turbogears.config 45 self.start_extension = self.start 46 self.shutdown_extension = self.stop 23 47 24 def _load_class(self, classpath): 25 components = classpath.split(':') 26 27 try: 28 module = __import__(components[0], globals(), locals(), [components[1]]) 29 except ImportError: 30 return None 31 32 return getattr(module, components[1]) 48 def load_single_entry(group, name): 49 for entrypoint in pkg_resources.iter_entry_points("turbogears.command"): 50 if entrypoint.name == name: 51 return entrypoint.load() 52 return None 33 53 34 def start _extension(self):54 def start(self): 35 55 """TurboGears extension startup. 36 56 … … 39 59 """ 40 60 41 if not self.config.get("mail.on", False):61 if not turbomail.config.get("mail.on", False): 42 62 return 43 63 … … 45 65 46 66 # Load the requested pool manager. 47 classpath = self.config.get("mail.manager", "turbomail.managers.demand:DemandManager") 48 turbomail.manager = self._load_class(classpath)(self.config) 67 manager = turbomail.config.get("mail.manager", "demand") 68 turbomail.manager = self.load_single_entry("turbomail.managers", manager) 69 if not turbomail.manager: 70 turbomail.config.set("mail.on", False) 71 log.error("Unable to locate %s manager, TurboMail disabled." % manager) 72 return 73 turbomail.manager.start() 49 74 50 75 # Load the requested mail provider. 51 classpath = self.config.get("") 76 provider = turbomail.config.get("mail.provider", "smtp") 77 turbomail.provider = self.load_single_entry("turbomail.providers", provider) 78 if not turbomail.provider: 79 turbomail.config.set("mail.on", False) 80 log.error("Unable to locate %s provider, TurboMail disabled." % provider) 81 return 82 turbomail.provider.start() 52 83 53 if self.config.get("mail.default.encoding", "us-ascii") == "utf-8-qp": 84 # Override the UTF-8 character set to use the quoted printable encoding. 85 if turbomail.config.get("mail.default.encoding", "us-ascii") == "utf-8-qp": 54 86 Charset.add_charset('utf-8', Charset.SHORTEST, Charset.QP, 'utf-8') 55 self.config.update({"mail.default.encoding": "utf-8"}) 87 turbomail.config.update({"mail.default.encoding": "utf-8"}) 88 89 # Load and initalize the various extensions. 90 extensions = pkg_resources.iter_entry_points("turbomail.extensions") 91 for entrypoint in extensions: 92 ext = entrypoint.load() 93 if hasattr(ext, "start"): 94 ext.start() 56 95 57 96 self.running = True 58 97 59 def s hutdown_extension(self):98 def stop(self): 60 99 """TurboGears extension shutdown. 61 100 … … 68 107 log.info("TurboMail extension shutting down.") 69 108 109 # Unload the various extensions. 110 extensions = pkg_resources.iter_entry_points("turbomail.extensions") 111 for entrypoint in extensions: 112 ext = entrypoint.load() 113 if hasattr(ext, "unload"): 114 ext.unload() 115 116 # Unload the provider and manager. 117 turbomail.provider.stop() 118 turbomail.manager.stop() 119 70 120 self.running = False 71 121
