Changeset 26

Show
Ignore:
Timestamp:
10/16/07 03:13:30 (1 year ago)
Author:
amcgregor
Message:

Applied testmode.patch and guide_testmode_doc.patch as per ticket #18.

Location:
branches/2.0.5
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • branches/2.0.5/documentation/guide.wiki

    r23 r26  
    4646    * `utf-8-qp` -- Configures utf-8 to use quoted-printable encoding.  (Note: this is not a real character set and can only be used with !TurboMail.  Note also that this setting reconfigures the global ''utf-8'' setting to use a different encoding and will effect other processes using this mechanism.) 
    4747 * `mail.polling` (Default: ''False'') If enabled, configures the thread pool to poll every mail.interval seconds for new jobs. This may give performance benefits to the running application. The default behaviour is to create new threads as soon as work is enqueued, resulting in faster delivery, but greater initial load. 
     48 * `mail.testmode` (Default: ''False'') If enabled, configures TurboMail NOT to send any mail to the specified server. Enqueued mails will just sit in the queue. This is very useful for unit tests where no interaction with the environment should take place.  
    4849 
    4950In debug mode, using a single thread with a maximum of one job can be advantageous. Having a single thread with a maximum of a single job limits !TurboMail to a single SMTP connection at a time and automatically disconnects after sending each message. 
  • branches/2.0.5/turbomail/pool.py

    r24 r26  
    2323        """ 
    2424         
    25         def __init__(self, interval=10, threads=4, jobs=10, timeout=60, polling=False, **kw): 
     25        def __init__(self, interval=10, threads=4, jobs=10, timeout=60, polling=False, testmode=False, **kw): 
    2626                """Initialize the thread pool. 
    2727                 
     
    4444                                as required, when work is enqueued. 
    4545                @type polling: bool 
     46 
     47                @param testmode: Enable or disable the unit testing mode.  
     48                                Disabled, no mail is actually sent but only 
     49                                stored in the queue for later retrieval. 
     50                @type testmode: bool 
    4651                """ 
    4752                 
     
    5661                self._timeout = timeout 
    5762                self._polling = False 
     63                self._testmode = testmode 
    5864                self._kw = kw 
    5965                 
     
    8591                else: 
    8692                        self._queue.put(work, block=block, timeout=timeout) 
     93 
     94                if self._testmode: 
     95                        log.debug("Testmode enabled, not sending mail.") 
     96                        return 
    8797                 
    8898                optimum_threads = min(self._threads, math.ceil(self._queue.qsize() / float(self._jobs))) 
  • branches/2.0.5/turbomail/startup.py

    r1 r26  
    4747                        debug=turbogears.config.get("mail.debug", False), 
    4848                        tls=turbogears.config.get("mail.tls", None), 
    49                         polling=turbogears.config.get("mail.polling", None) 
     49                        polling=turbogears.config.get("mail.polling", None), 
     50                        testmode=turbogears.config.get("mail.testmode", False) 
    5051                ) 
    5152