当前位置: 首页>>代码示例>>Python>>正文


Python Configurator.end方法代码示例

本文整理汇总了Python中repoze.bfg.configuration.Configurator.end方法的典型用法代码示例。如果您正苦于以下问题:Python Configurator.end方法的具体用法?Python Configurator.end怎么用?Python Configurator.end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在repoze.bfg.configuration.Configurator的用法示例。


在下文中一共展示了Configurator.end方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestRun

# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import end [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())
开发者ID:reedobrien,项目名称:tattoo,代码行数:37,代码来源:tests.py

示例2: main

# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import end [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
开发者ID:wichert,项目名称:checking,代码行数:32,代码来源:run.py

示例3: app

# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import end [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()
开发者ID:FvD,项目名称:cobal.eportfolio,代码行数:27,代码来源:run.py

示例4: CodecTests

# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import end [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)
开发者ID:reedobrien,项目名称:tattoo,代码行数:33,代码来源:tests.py

示例5: ModelUtilTests

# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import end [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")
开发者ID:shentonfreude,项目名称:rfd,代码行数:31,代码来源:tests.py

示例6: app

# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import end [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()
开发者ID:vilos,项目名称:rstlibrary,代码行数:31,代码来源:run.py

示例7: app

# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import end [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()
开发者ID:bluedynamics,项目名称:bda.bfg.ugm,代码行数:11,代码来源:run.py

示例8: maintenance

# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import end [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()
开发者ID:cguardia,项目名称:karl,代码行数:12,代码来源:maintenance.py

示例9: app

# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import end [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()
开发者ID:shentonfreude,项目名称:fare,代码行数:14,代码来源:run.py

示例10: ViewTests

# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import end [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')
开发者ID:mitchellrj,项目名称:BMI-Bargains,代码行数:15,代码来源:tests.py

示例11: BaseTest

# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import end [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()
开发者ID:seantis,项目名称:seantisinvoice,代码行数:15,代码来源:tests.py

示例12: ViewTests

# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import end [as 别名]
class ViewTests(unittest.TestCase):
    def setUp(self):
        self.config = Configurator()
        self.config.begin()

    def tearDown(self):
        self.config.end()

    def test_filedrop_view(self):
        from rfd.views import filedrop
        request = testing.DummyRequest()
        context = None          # this can't be right
        info = filedrop(context, request)
        self.assertEqual(info['project'], 'rfd (repoze file drop)')
开发者ID:shentonfreude,项目名称:rfd,代码行数:16,代码来源:tests.py

示例13: TestUtility

# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import end [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)
开发者ID:reedobrien,项目名称:tattoo,代码行数:16,代码来源:tests.py

示例14: ViewTests

# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import end [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")
开发者ID:shentonfreude,项目名称:DubCore,代码行数:16,代码来源:tests.py

示例15: ModelTests

# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import end [as 别名]
class ModelTests(unittest.TestCase):
    def setUp(self):
        self.config = Configurator()
        self.config.begin()
    
    def tearDown(self):
        self.config.end()

    def test_url_model(self):
        from tattoo.models import URL
        url = URL(1234, 'long', 'short')
        self.assertEquals(url._id, 1234)
        self.assertEquals(url.url, 'long')
        self.assertEquals(url.short_url, 'short')
        self.assertEquals(type(url.created), type(datetime.datetime.now()))
开发者ID:reedobrien,项目名称:tattoo,代码行数:17,代码来源:tests.py


注:本文中的repoze.bfg.configuration.Configurator.end方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。