本文整理汇总了Python中pyramid_mailer.mailer.Mailer.from_settings方法的典型用法代码示例。如果您正苦于以下问题:Python Mailer.from_settings方法的具体用法?Python Mailer.from_settings怎么用?Python Mailer.from_settings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyramid_mailer.mailer.Mailer
的用法示例。
在下文中一共展示了Mailer.from_settings方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from pyramid_mailer.mailer import Mailer [as 别名]
# 或者: from pyramid_mailer.mailer.Mailer import from_settings [as 别名]
def main(global_config, **settings):
"""
This function returns a Pyramid WSGI application.
"""
# the database session:
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
Base.metadata.bind = engine
# session_factory = session_factory_from_settings(settings)
config = Configurator(
settings=settings,
root_factory=get_root,
authentication_policy=GyAuthenticationPolicy(),
authorization_policy=GyAuthorizationPolicy(),
session_factory = session_factory_from_settings(settings),
request_factory = GyRequest,
)
config.add_static_view('static', 'static', cache_max_age=3600)
# config.include('pyramid_mailer')
mailer = Mailer.from_settings(settings)
config.registry['mailer'] = mailer
config.include('gy.core')
config.include('gy.blog')
config.add_notfound_view(gy_not_found, append_slash=True)
config.scan()
return config.make_wsgi_app()
示例2: main
# 需要导入模块: from pyramid_mailer.mailer import Mailer [as 别名]
# 或者: from pyramid_mailer.mailer.Mailer import from_settings [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application. """
config = Configurator(settings=settings)
#set up beaker session
session_factory = session_factory_from_settings(settings)
config.set_session_factory(session_factory)
# add security tweens
# config.add_tween('aws_demo.tweens.clickjacking.clickjacking_factory')
# config.add_tween('aws_demo.tweens.secure_headers.secure_headers_factory')
config.registry['mailer'] = Mailer.from_settings(settings=settings)
# modify the built in json renderer to serialize dates properly
json_date_renderer = JSON()
json_date_renderer.add_adapter(datetime.datetime, new_datetime_adapter)
# set .html renderer to allow mako templating
config.add_renderer('.html', 'pyramid.mako_templating.renderer_factory')
config.add_renderer('.htm', 'pyramid.mako_templating.renderer_factory')
config.add_renderer('json', json_date_renderer)
config.add_static_view('static', 'static', cache_max_age=3600)
# login / registration
config.add_route('index_view', '/')
config.scan()
return config.make_wsgi_app()
示例3: main
# 需要导入模块: from pyramid_mailer.mailer import Mailer [as 别名]
# 或者: from pyramid_mailer.mailer.Mailer import from_settings [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
engine = engine_from_config(settings, "sqlalchemy.")
DBSession.configure(bind=engine)
Base.metadata.bind = engine
authn_policy = AuthTktAuthenticationPolicy("sosecret", callback=groupfinder, hashalg="sha512")
authz_policy = ACLAuthorizationPolicy()
config = Configurator(settings=settings, root_factory="webapp.models.RootFactory")
config.set_authentication_policy(authn_policy)
config.set_authorization_policy(authz_policy)
config.registry["mailer"] = Mailer.from_settings(settings)
config.add_static_view("static", "static", cache_max_age=3600)
config.add_route("index", "/")
config.add_route("login", "/login")
config.add_route("logout", "/logout")
config.add_route("registration", "/registration")
# config.add_route('end_reg', '/activate/{a_code}')
config.add_route("verify", "/verify/{code}")
# config.add_route('confirm', '/confirm')
config.add_route("content", "/content/{id}")
config.add_route("about", "/about")
config.add_route("pay", "/pay")
config.add_route("preview", "/preview")
config.add_route("bundle_preview", "/bundle_preview")
config.add_route("b_content", "/bonus/{id}")
config.add_route("bundle", "/bundle/{id}")
config.add_route("account", "/account/{parameters}")
config.scan()
return config.make_wsgi_app()
示例4: main
# 需要导入模块: from pyramid_mailer.mailer import Mailer [as 别名]
# 或者: from pyramid_mailer.mailer.Mailer import from_settings [as 别名]
def main(argv=sys.argv):
if len(argv) != 2:
usage(argv)
config_uri = argv[1]
setup_logging(config_uri)
settings = get_appsettings(config_uri)
engine = engine_from_config(settings, "sqlalchemy.")
mailer = Mailer.from_settings(settings)
DBSession.configure(bind=engine)
rootFolder = settings["reports.folder"]
request = Request.blank("/", base_url=settings["reports.app.url"])
env = bootstrap(config_uri, request=request)
request = env["request"]
try:
remove_groups(request)
remove_reports(request)
handleRootFolder(request, rootFolder)
# email_users(request, mailer)
email_admin_users(request, mailer)
transaction.commit()
except Exception as e:
transaction.abort()
stack = traceback.format_exc()
body = "Got an exception while processing reports: %s\n\n%s" % (e, stack)
message = Message(
subject="Famoso Reports - failed to process",
sender="[email protected]",
recipients=["[email protected]"],
body=body,
)
mailer.send_immediately(message)
示例5: mailer_factory_from_settings
# 需要导入模块: from pyramid_mailer.mailer import Mailer [as 别名]
# 或者: from pyramid_mailer.mailer.Mailer import from_settings [as 别名]
def mailer_factory_from_settings(settings, prefix='mail.'):
"""
Factory function to create a Mailer instance from settings.
Equivalent to **Mailer.from_settings**
:versionadded: 0.2.2
"""
return Mailer.from_settings(settings, prefix)
示例6: mailer_factory_from_settings
# 需要导入模块: from pyramid_mailer.mailer import Mailer [as 别名]
# 或者: from pyramid_mailer.mailer.Mailer import from_settings [as 别名]
def mailer_factory_from_settings(settings, prefix='mail.'):
"""
Factory function to create a Mailer instance from settings.
Equivalent to :meth:`pyramid_mailer.mailer.Mailer.from_settings`.
:versionadded: 0.2.2
"""
return Mailer.from_settings(settings, prefix)
示例7: main
# 需要导入模块: from pyramid_mailer.mailer import Mailer [as 别名]
# 或者: from pyramid_mailer.mailer.Mailer import from_settings [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
authentication_policy = AuthTktAuthenticationPolicy('seekrit', callback=groupfinder)
authorization_policy = ACLAuthorizationPolicy()
engine = engine_from_config(settings, prefix='sqlalchemy.')
db_maker = sessionmaker(bind=engine)
settings['rel_db.sessionmaker'] = db_maker
config = Configurator(settings=settings,
root_factory='scielobooks.resources.RootFactory',
authentication_policy=authentication_policy,
authorization_policy=authorization_policy,
request_factory=MyRequest,
renderer_globals_factory=renderer_globals_factory)
config.include(pyramid_zcml)
config.load_zcml('configure.zcml')
config.include('pyramid_mailer')
config.include('pyramid_celery')
config.registry['mailer'] = Mailer.from_settings(settings)
config.registry['app_version'] = APP_VERSION
db_uri = settings['db_uri']
conn = couchdbkit.Server(db_uri)
config.registry.settings['db_conn'] = conn
config.add_subscriber(add_couch_db, NewRequest)
config.scan('scielobooks.models')
initialize_sql(engine)
if settings['serve_static_files'] == 'true':
config.add_static_view(name='static', path='static')
config.add_static_view('deform_static', 'deform:static')
config.add_static_view('/'.join((settings['db_uri'], settings['db_name'])), 'scielobooks:database')
config.add_static_view(settings['fileserver_url'], 'scielobooks:fileserver')
config.add_view(custom_forbidden_view, context=Forbidden)
config.add_translation_dirs('scielobooks:locale/')
config.set_locale_negotiator(custom_locale_negotiator)
my_session_factory = UnencryptedCookieSessionFactoryConfig('itsaseekreet')
config.set_session_factory(my_session_factory)
application = config.make_wsgi_app()
try:
if settings.get('newrelic.enable', 'False').lower() == 'true':
newrelic.agent.initialize(os.path.join(APP_PATH, '..', 'newrelic.ini'), settings['newrelic.environment'])
return newrelic.agent.wsgi_application()(application)
else:
return application
except IOError:
config.registry.settings['newrelic.enable'] = False
return application
示例8: __init__
# 需要导入模块: from pyramid_mailer.mailer import Mailer [as 别名]
# 或者: from pyramid_mailer.mailer.Mailer import from_settings [as 别名]
def __init__(self, *args, **settings):
if len(args) == 1:
# regular app
app = None
else:
app = args[0]
self.initialize_settings(app, settings)
# db configuration
db_factory_name = settings.get('db_factory_name', 'sql')
if db_factory_name not in db_factories:
raise Exception("Invalid db_factory_name: %s" % db_factory_name)
settings['db_session_id'], self.db = db_factories[db_factory_name](settings, self) # noqa
self.setup_autouserfinder(settings)
# start pyramid application configuration
config = Configurator(settings=settings, request_factory=Request)
try:
import pyramid_chameleon # noqa
config.include('pyramid_chameleon')
except ImportError:
pass
self.setup_plugins(config, settings)
from factored.views import auth_chooser, notfound
config.add_route('auth', self.base_auth_url)
config.add_view(auth_chooser, route_name='auth',
renderer='templates/layout.pt')
# setup template customization registration
if TEMPLATE_CUSTOMIZATIONS not in config.registry:
config.registry[TEMPLATE_CUSTOMIZATIONS] = {}
# static paths for resources
self.static_path = os.path.join(self.base_auth_url, 'authstatic')
config.add_static_view(name=self.static_path,
path='factored:static')
config.add_notfound_view(notfound, append_slash=True)
# add some things to registry
config.registry['mailer'] = Mailer.from_settings(settings)
config.registry['settings'] = self.__dict__
config.registry['formtext'] = nested_settings(
get_settings(settings, 'formtext.'))
config.registry['app'] = self
config.scan()
self.config = config
self.registry = self.config.registry
try:
self.app.config.registry['factored'] = self
except:
pass
self.pyramid = config.make_wsgi_app()
示例9: init_mailer
# 需要导入模块: from pyramid_mailer.mailer import Mailer [as 别名]
# 或者: from pyramid_mailer.mailer.Mailer import from_settings [as 别名]
def init_mailer(config, mailer=None):
settings = config.registry.settings
settings['mail.default_sender'] = settings.get(
'mail.default_sender',
formataddr(('Site administrator', '[email protected]')))
if not mailer:
mailer = Mailer.from_settings(settings)
config.registry.registerUtility(mailer, IMailer)
log.info("Initialize mailer")
示例10: main
# 需要导入模块: from pyramid_mailer.mailer import Mailer [as 别名]
# 或者: from pyramid_mailer.mailer.Mailer import from_settings [as 别名]
def main():
if len(sys.argv) < 2:
usage(sys.argv)
config_uri = sys.argv[1]
setup_logging(config_uri)
settings = get_appsettings(config_uri)
engine = engine_from_config(settings, 'sqlalchemy.')
Session.configure(bind=engine)
mailer = Mailer.from_settings(settings)
ldap_conn = helper.connect()
for line in sys.stdin:
merge_to_umail(ldap_conn, mailer, *line.strip().split())
transaction.commit()
示例11: __init__
# 需要导入模块: from pyramid_mailer.mailer import Mailer [as 别名]
# 或者: from pyramid_mailer.mailer.Mailer import from_settings [as 别名]
def __init__(self, *args, **settings):
if len(args) == 1:
# regular app
app = None
else:
app = args[0]
self.initialize_settings(app, settings)
# db configuration
engine = engine_from_config(settings, 'sqlalchemy.')
configure_db = settings.pop('configure_db', 'true').lower() == 'true'
if configure_db:
DBSession.configure(bind=engine)
self.db_session_id = 'f'
else:
self.db_session_id = settings.pop('db_session_id')
self.setup_autouserfinder(settings)
# start pyramid application configuration
config = Configurator(settings=settings, request_factory=Request)
self.setup_plugins(config, settings)
from factored.views import auth_chooser, notfound
config.add_route('auth', self.base_auth_url)
config.add_view(auth_chooser, route_name='auth',
renderer='templates/layout.pt')
# setup template customization registration
if TEMPLATE_CUSTOMIZATIONS not in config.registry:
config.registry[TEMPLATE_CUSTOMIZATIONS] = {}
# static paths for resources
self.static_path = os.path.join(self.base_auth_url, 'authstatic')
config.add_static_view(name=self.static_path,
path='factored:static')
config.add_notfound_view(notfound, append_slash=True)
# add some things to registry
config.registry['mailer'] = Mailer.from_settings(settings)
config.registry['settings'] = self.__dict__
config.registry['formtext'] = nested_settings(
get_settings(settings, 'formtext.'))
config.registry['app'] = self
config.scan()
self.pyramid = config.make_wsgi_app()
示例12: main
# 需要导入模块: from pyramid_mailer.mailer import Mailer [as 别名]
# 或者: from pyramid_mailer.mailer.Mailer import from_settings [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
l = LoginDAO()
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
Base.metadata.bind = engine
authn_policy = AuthTktAuthenticationPolicy('sosecret', callback=l.groupfinder, hashalg='sha512')
authz_policy = ACLAuthorizationPolicy()
config = Configurator(settings=settings, root_factory="terminus.models.Login")
config.registry['mailer'] = Mailer.from_settings(settings)
config.set_session_factory(my_session_factory)
config.set_authentication_policy(authn_policy)
config.set_authorization_policy(authz_policy)
config.include('pyramid_chameleon')
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_route('home', '/')
#Admin routes
config.add_route('adm', '/adm')
config.add_route('clientes', '/adm/clientes')
config.add_route('gerentes', '/adm/gerentes')
config.add_route('novoprojeto', '/adm/novoprojeto')
config.add_route('novogerente', '/adm/novogerente')
config.add_route('addgerente', '/adm/addgerente')
config.add_route('editargerente', '/adm/{id}/editargerente')
config.add_route('deletargerente', '/adm/{id}/deletargerente')
config.add_route('deletarcliente', '/adm/{id}/deletarcliente')
config.add_route('atualizargerente', '/adm/atualizargerente')
config.add_route('novocliente', '/adm/novocliente')
config.add_route('addcliente', '/adm/addcliente')
config.add_route('projeto', '/adm/projeto/{pid}/')
config.add_route('addprojeto', '/adm/addprojeto')
config.add_route('tarefa', '/adm/projeto/{id}/addtarefa')
config.add_route('finalizar-tarefa', '/adm/projeto/{id}/finalizar/{status}/{pid}')
config.add_route("responder-alteracao","adm/{id}/responderalteracao/{pid}")
config.add_route("configuracoes","/adm/configuracoes")
config.add_route("cadastro-email","/adm/cadastro-email/")
config.add_route("atualizar-email","/adm/atualizar-email/")
#Client routes
config.add_route('login-gerentes', '/adm/login')
config.add_route("cliente-index","/{id}/index")
config.add_route("cliente-dados","/{id}/dados")
config.add_route("cliente-atualizar","/{id}/atualizarcliente")
config.add_route("projeto-cliente","/{id}/projeto/{pid}")
config.add_route("projeto-aprovacao","/{id}/projetoaprovacao/{pid}")
config.add_route("solicitar-alteracao","/{id}/solicitaralteracao/{pid}")
config.scan()
return config.make_wsgi_app()
示例13: main
# 需要导入模块: from pyramid_mailer.mailer import Mailer [as 别名]
# 或者: from pyramid_mailer.mailer.Mailer import from_settings [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
authentication_policy = AuthTktAuthenticationPolicy('seekrit', callback=groupfinder)
authorization_policy = ACLAuthorizationPolicy()
engine = engine_from_config(settings, prefix='sqlalchemy.')
db_maker = sessionmaker(bind=engine)
settings['rel_db.sessionmaker'] = db_maker
config = Configurator(settings=settings,
root_factory='scielobooks.resources.RootFactory',
authentication_policy=authentication_policy,
authorization_policy=authorization_policy,
request_factory=MyRequest)
config.include(pyramid_zcml)
config.load_zcml('configure.zcml')
config.include('pyramid_mailer')
config.registry['mailer'] = Mailer.from_settings(settings)
db_uri = settings['db_uri']
conn = couchdbkit.Server(db_uri)
config.registry.settings['db_conn'] = conn
config.add_subscriber(add_couch_db, NewRequest)
config.scan('scielobooks.models')
initialize_sql(engine)
if settings['serve_static_files'] == 'true':
config.add_static_view(name='static', path='static')
config.add_static_view('deform_static', 'deform:static')
config.add_static_view(settings['books_static_url'], 'scielobooks:books')
config.add_static_view('/'.join((settings['db_uri'], settings['db_name'])), 'scielobooks:database')
config.add_view(custom_forbidden_view, context=Forbidden)
config.add_translation_dirs('scielobooks:locale/')
config.set_locale_negotiator(custom_locale_negotiator)
my_session_factory = UnencryptedCookieSessionFactoryConfig('itsaseekreet')
config.set_session_factory(my_session_factory)
return config.make_wsgi_app()
示例14: main
# 需要导入模块: from pyramid_mailer.mailer import Mailer [as 别名]
# 或者: from pyramid_mailer.mailer.Mailer import from_settings [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
# Authentication & authorisation
authentication_policy = AuthTktAuthenticationPolicy('seekrit', callback=groupfinder)
authorization_policy = ACLAuthorizationPolicy()
# Sessions
session_factory = pyramid_beaker.session_factory_from_settings(settings)
config = Configurator(
root_factory=Root,
settings=settings,
authentication_policy=authentication_policy,
authorization_policy=authorization_policy,
session_factory=session_factory,
)
# Add helpers to render
config.add_subscriber(add_renderer_globals, BeforeRender)
# MongoDB related
db_uri = settings['db_uri']
conn = pymongo.Connection(db_uri)
config.registry.settings['db_conn'] = conn
config.add_subscriber(add_mongo_db, NewRequest)
# Delete if running in development mode
if settings['db.reset'] == 'true':
conn.drop_database(settings['db_name'])
initialize_mongo(conn[settings['db_name']])
dbupdates.update(conn[settings['db_name']])
# Mailer
config.include('pyramid_mailer')
config.registry['mailer'] = Mailer.from_settings(settings)
# CSRF check
config.add_subscriber(csrf_validation, NewRequest)
config.add_static_view('static', 'formative:static')
config.scan()
return config.make_wsgi_app()
示例15: __init__
# 需要导入模块: from pyramid_mailer.mailer import Mailer [as 别名]
# 或者: from pyramid_mailer.mailer.Mailer import from_settings [as 别名]
def __init__(self, access_token, search_fields, keywords, mail_settings=None,
mail_targets=None):
self.access_token = access_token
self.search_fields = search_fields
self.keywords = keywords
self.regex_get_keywords = re.compile("[\w']+")
self.processed_posts = collections.Counter()
self.keyword_frequency = collections.Counter()
self.run_count = 0
self.failure_count = 0
if mail_settings is not None:
self.mailer = Mailer.from_settings(mail_settings)
self.mail_settings = mail_settings
self.mail_targets = mail_targets
else:
self.mailer = None
self.mail_settings = None
self.mail_targets = None