本文整理汇总了Python中repoze.bfg.configuration.Configurator.begin方法的典型用法代码示例。如果您正苦于以下问题:Python Configurator.begin方法的具体用法?Python Configurator.begin怎么用?Python Configurator.begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类repoze.bfg.configuration.Configurator
的用法示例。
在下文中一共展示了Configurator.begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import begin [as 别名]
def main(global_config, **settings):
""" This function returns a WSGI application.
It is usually called by the PasteDeploy framework during
``paster serve``.
"""
from repoze.bfg.authentication import AuthTktAuthenticationPolicy
from checking.authorization import RouteAuthorizationPolicy
from checking.authentication import verifyUser
if not settings.get("sqlalchemy.url"):
raise ValueError("No 'sqlalchemy.url' value in application configuration.")
config = Configurator(settings=settings,
authentication_policy=AuthTktAuthenticationPolicy("secret",
callback=verifyUser,
timeout=30*60, max_age=30*60,
reissue_time=20*60),
authorization_policy=RouteAuthorizationPolicy())
config.hook_zca()
config.begin()
setupSqlalchemy(settings)
setupRoutes(config)
setupChameleon(config)
setupi18n(config)
config.end()
app = config.make_wsgi_app()
app = TM(app)
return app
示例2: app
# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import begin [as 别名]
def app(global_config, **settings):
""" This function returns a WSGI application.
It is usually called by the PasteDeploy framework during
``paster serve``.
"""
names = ('src_path', 'store_url', 'cache_url', 'max_entries', 'database', 'content_dir')
values = []
for name in names:
val = settings.get(name)
if val is None:
raise ValueError("No ’%s’ value in application configuration." % name)
values.append(val)
src_path, store_url, cache_url, max_entries, database, content_dir = values
zcml_file = settings.get('configure_zcml', 'configure.zcml')
config = Configurator(settings=settings, root_factory=ContentRoot(content_dir))
# use local component registry
config.hook_zca()
config.begin()
config.load_zcml(zcml_file)
register_source(src_path)
register_store(store_url, cache_url, max_entries=max_entries)
register_catalog(database)
config.end()
return config.make_wsgi_app()
示例3: app
# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import begin [as 别名]
def app(global_config, **settings):
""" This function returns a WSGI application.
It is usually called by the PasteDeploy framework during
``paster serve``.
"""
zcml_file = settings.get('configure_zcml', 'configure.zcml')
db_string = settings.get('db_string')
if db_string is None:
raise ValueError("No 'db_string' value in application configuration.")
initialize_sql(db_string)
config = Configurator(root_factory=get_root, settings=settings)
config.begin()
config.load_zcml(zcml_file)
config.end()
# Ugly hack to configure the MapperExtension with the settings.
removal_extension.path = settings.get('upload_directory')
scheduler = Scheduler()
# Send out queued mails
from eportfolio.utilities.mail_delivery import trigger_queued_delivery
scheduler.add_interval_job(trigger_queued_delivery, seconds=30)
scheduler.start()
return config.make_wsgi_app()
示例4: CodecTests
# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import begin [as 别名]
class CodecTests(unittest.TestCase):
def setUp(self):
self.config = Configurator()
self.config.begin()
def tearDown(self):
self.config.end()
def _make_codec(self):
from tattoo.codec import decode, encode, map_dict
CHARS = u"ABC123.ä~€+"
BASE = len(CHARS)
map_dict.clear()
for num in range(BASE):
map_dict[num] = CHARS[num]
map_dict[CHARS[num]] = num
return decode, encode, map_dict
def test_encode(self):
decode, encode, map_dict = self._make_codec()
self.assertEqual(encode(0), u'A')
self.assertEqual(encode(10), u'+')
self.assertEqual(encode(7), u'\xe4')
self.assertEqual(encode(4), u'2')
def test_decode(self):
decode, encode, map_dict = self._make_codec()
self.assertEqual(decode(u'A'), 0)
self.assertEqual(decode(u'+'), 10)
self.assertEqual(decode(u'\xe4'), 7)
self.assertEqual(decode(u'2'), 4)
示例5: ModelUtilTests
# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import begin [as 别名]
class ModelUtilTests(unittest.TestCase):
def setUp(self):
self.config = Configurator()
self.config.begin()
def tearDown(self):
self.config.end()
def test_create_child_no_kwargs(self):
from rfd.models import create_child
class Thing(object):
pass
parent = Thing()
name = "alice"
child = create_child(Thing, parent, name)
self.assertEqual(child.__parent__, parent)
self.assertEqual(child.__name__, name)
def test_create_child_with_kwargs(self):
from rfd.models import create_child
class Thing(object):
pass
parent = Thing()
name = "alice"
child = create_child(Thing, parent, name, foo="foo", bar="bar")
self.assertEqual(child.__parent__, parent)
self.assertEqual(child.__name__, name)
self.assertEqual(child.foo, "foo")
self.assertEqual(child.bar, "bar")
示例6: TestRun
# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import begin [as 别名]
class TestRun(unittest.TestCase):
def setUp(self):
self.config = Configurator()
self.config.begin()
def tearDown(self):
self.config.end()
def test_app(self):
from tattoo.run import app
myapp = app(None,
setup_db=setup_db,
populate=populate,
db_path='mongo://foo.com:1235/dbname',
min_url_len=21,
)
self.assertEquals(myapp.__class__.__name__, 'Router')
def test_app_without_db_string(self):
from tattoo.run import app
self.assertRaises(ValueError, app,
None,
setup_db=setup_db,
populate=populate,
min_url_len=21,
)
def test_setup_db(self):
from tattoo.run import setup_db
from ming import Session
from tattoo.models import SESSION_NAME
db_uri = 'mongo://foo.com:1235/dbname'
setup_db(db_uri)
session = Session.by_name(SESSION_NAME)
self.assertTrue(SESSION_NAME in session._registry.keys())
示例7: EPortfolioIntegrationTestCase
# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import begin [as 别名]
class EPortfolioIntegrationTestCase(EPortfolioTestCase):
def setUp(self):
self.config = Configurator()
self.config.hook_zca()
self.config.begin()
self.config.load_zcml('eportfolio:configure.zcml')
_initTestingDB()
示例8: app
# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import begin [as 别名]
def app(global_config, **settings):
""" This function returns a WSGI application.
"""
zcml_file = settings.get('configure_zcml', 'configure.zcml')
config = Configurator(root_factory=get_root, settings=settings)
config.begin()
config.load_zcml(zcml_file)
config.end()
return config.make_wsgi_app()
示例9: maintenance
# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import begin [as 别名]
def maintenance(global_config, **local_conf):
config = Configurator()
config.begin()
config.add_static_view('static', 'karl.views:static')
config.add_route(name='maintenance',
path='/*url',
view=dummy_view,
view_renderer='down_for_maintenance.pt')
config.end()
return config.make_wsgi_app()
示例10: ViewIntegrationTest
# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import begin [as 别名]
class ViewIntegrationTest(ViewTest):
def setUp(self):
import seantisinvoice
self.config = Configurator(package=seantisinvoice)
self.config.begin()
self.config.load_zcml("seantisinvoice:configure.zcml")
_initTestingDB()
def test_zcml_registration(self):
pass
示例11: app
# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import begin [as 别名]
def app(global_config, **settings):
""" This function returns a WSGI application.
It is usually called by the PasteDeploy framework during
``paster serve``.
"""
config = Configurator()
config.begin()
config.add_view(home, renderer="templates/home.pt")
config.add_view(expense, name='expense', renderer='templates/expense.pt')
config.end()
return config.make_wsgi_app()
示例12: ViewTests
# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import begin [as 别名]
class ViewTests(unittest.TestCase):
def setUp(self):
self.config = Configurator()
self.config.begin()
def tearDown(self):
self.config.end()
def test_my_view(self):
from bmibargains.views import my_view
request = testing.DummyRequest()
info = my_view(request)
self.assertEqual(info['project'], 'bmibargains')
示例13: BaseTest
# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import begin [as 别名]
class BaseTest(unittest.TestCase):
def setUp(self):
self.config = Configurator()
self.config.begin()
_initTestingDB()
def tearDown(self):
from seantisinvoice.models import DBSession
import transaction
DBSession.remove()
transaction.abort()
self.config.end()
示例14: TestUtility
# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import begin [as 别名]
class TestUtility(unittest.TestCase):
def setUp(self):
self.config = Configurator()
self.config.begin()
def tearDown(self):
self.config.end()
def test_expire_one_year(self):
import datetime
from tattoo.utility import expire_one_year
nowish = datetime.datetime.now()
delta = expire_one_year()-nowish
self.assertEquals(delta.days, 365)
示例15: ViewTests
# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import begin [as 别名]
class ViewTests(unittest.TestCase):
def setUp(self):
self.config = Configurator()
self.config.begin()
def tearDown(self):
self.config.end()
def test_my_view(self):
from dubcore.views import my_view
request = testing.DummyRequest()
info = my_view(request)
self.assertEqual(info["project"], "dubcore")