src/pyams_mail/include.py
changeset 0 f02739a295b2
child 1 120f4f401a6a
equal deleted inserted replaced
-1:000000000000 0:f02739a295b2
       
     1 #
       
     2 # Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
       
     3 # All Rights Reserved.
       
     4 #
       
     5 # This software is subject to the provisions of the Zope Public License,
       
     6 # Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
       
     7 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
       
     8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
       
     9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
       
    10 # FOR A PARTICULAR PURPOSE.
       
    11 #
       
    12 
       
    13 __docformat__ = 'restructuredtext'
       
    14 
       
    15 
       
    16 # import standard library
       
    17 
       
    18 # import interfaces
       
    19 from pyramid_mailer.interfaces import IMailer
       
    20 
       
    21 # import packages
       
    22 from pyramid_mailer.mailer import Mailer
       
    23 
       
    24 
       
    25 def include_package(config):
       
    26     """Pyramid include"""
       
    27 
       
    28     # add translations
       
    29     config.add_translation_dirs('pyams_mail:locales')
       
    30 
       
    31     # load registry components
       
    32     config.scan()
       
    33 
       
    34     if hasattr(config, 'load_zcml'):
       
    35         config.load_zcml('configure.zcml')
       
    36 
       
    37     settings = config.registry.settings
       
    38     mailers = settings.get('pyams_mail.mailers')
       
    39     if mailers:
       
    40         for prefix in mailers.split():
       
    41             config.registry.registerUtility(Mailer.from_settings(settings, prefix), IMailer,
       
    42                                             name=settings['{0}name'.format(prefix)])