當前位置: 首頁>>代碼示例>>Python>>正文


Python config.Config類代碼示例

本文整理匯總了Python中morepath.config.Config的典型用法代碼示例。如果您正苦於以下問題:Python Config類的具體用法?Python Config怎麽用?Python Config使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Config類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_function_no_conflict_different_apps

def test_function_no_conflict_different_apps():
    app_a = morepath.App()
    app_b = morepath.App()

    def func(a):
        pass

    class A(object):
        pass

    a = app_a.function(func, A)
    a1 = app_b.function(func, A)

    @a
    def a_func(a):
        pass

    @a1
    def a1_func(a):
        pass

    c = Config()
    c.configurable(app_a)
    c.configurable(app_b)
    c.action(a, a_func)
    c.action(a1, a1_func)
    c.commit()
開發者ID:webmaven,項目名稱:morepath,代碼行數:27,代碼來源:test_directive.py

示例2: test_model_conflict

def test_model_conflict():
    app = morepath.App()

    class A(object):
        pass

    a = app.model(model=A, path='a')

    @a
    def get_a():
        return A()

    b = app.model(model=A, path='a')

    @b
    def get_a_again():
        return A()

    c = Config()
    c.configurable(app)
    c.action(a, get_a)
    c.action(b, get_a_again)

    with pytest.raises(ConflictError):
        c.commit()
開發者ID:webmaven,項目名稱:morepath,代碼行數:25,代碼來源:test_directive.py

示例3: test_function_conflict

def test_function_conflict():
    app = morepath.App()

    def func(a):
        pass

    class A(object):
        pass

    a = app.function(func, A)

    @a
    def a_func(arequest, model):
        pass

    a1 = app.function(func, A)

    @a1
    def a1_func(request, model):
        pass

    c = Config()
    c.configurable(app)
    c.action(a, a_func)
    c.action(a1, a1_func)

    with pytest.raises(ConflictError):
        c.commit()
開發者ID:webmaven,項目名稱:morepath,代碼行數:28,代碼來源:test_directive.py

示例4: test_model_no_conflict_different_apps

def test_model_no_conflict_different_apps():
    app_a = morepath.App()

    class A(object):
        pass

    a = app_a.model(model=A, path='a')

    @a
    def get_a():
        return A()

    app_b = morepath.App()

    b = app_b.model(model=A, path='a')

    @b
    def get_a_again():
        return A()

    c = Config()
    c.configurable(app_a)
    c.configurable(app_b)
    c.action(a, get_a)
    c.action(b, get_a_again)
    c.commit()
開發者ID:webmaven,項目名稱:morepath,代碼行數:26,代碼來源:test_directive.py

示例5: test_basic_json

def test_basic_json():
    setup()
    basic.app.clear()

    config = Config()
    config.scan(basic)
    config.commit()

    c = Client(basic.app, Response)

    response = c.get('/foo/json')

    assert response.data == '{"id": "foo"}'
開發者ID:kingel,項目名稱:morepath,代碼行數:13,代碼來源:test_directive.py

示例6: test_basic

def test_basic():
    setup()
    basic.app.clear()

    config = Config()
    config.scan(basic)
    config.commit()

    c = Client(basic.app, Response)

    response = c.get('/foo')

    assert response.data == 'The view for model: foo'

    response = c.get('/foo/link')
    assert response.data == 'foo'
開發者ID:kingel,項目名稱:morepath,代碼行數:16,代碼來源:test_directive.py

示例7: test_basic_root

def test_basic_root():
    setup()
    basic.app.clear()

    config = Config()
    config.scan(basic)
    config.commit()

    c = Client(basic.app, Response)

    response = c.get('/')

    assert response.data == 'The root: ROOT'

    # @@ is to make sure we get the view, not the sub-model
    response = c.get('/@@link')
    assert response.data == ''
開發者ID:kingel,項目名稱:morepath,代碼行數:17,代碼來源:test_directive.py

示例8: test_nested

def test_nested():
    setup()
    nested.outer_app.clear()
    nested.app.clear()

    config = Config()
    config.scan(nested)
    config.commit()

    c = Client(nested.outer_app, Response)

    response = c.get('/inner/foo')

    assert response.data == 'The view for model: foo'

    response = c.get('/inner/foo/link')
    assert response.data == 'inner/foo'
開發者ID:kingel,項目名稱:morepath,代碼行數:17,代碼來源:test_directive.py

示例9: test_no_path_conflict_with_variable_different_converters

def test_no_path_conflict_with_variable_different_converters():
    app = morepath.App()

    class A(object):
        pass

    class B(object):
        pass

    a = app.model(model=A, path='a/{id:int}')

    @a
    def get_a(id):
        return A()

    b = app.model(model=B, path='a/{id:str}')

    @b
    def get_b(id):
        return B()

    c = Config()
    c.configurable(app)
    c.action(a, get_a)
    c.action(b, get_b)

    c.commit()
開發者ID:webmaven,項目名稱:morepath,代碼行數:27,代碼來源:test_directive.py

示例10: test_path_conflict_with_variable

def test_path_conflict_with_variable():
    app = morepath.App()

    class A(object):
        pass

    class B(object):
        pass

    a = app.model(model=A, path='a/{id}')

    @a
    def get_a(id):
        return A()

    b = app.model(model=B, path='a/{id2}')

    @b
    def get_b(id):
        return B()

    c = Config()
    c.configurable(app)
    c.action(a, get_a)
    c.action(b, get_b)

    with pytest.raises(ConflictError):
        c.commit()
開發者ID:webmaven,項目名稱:morepath,代碼行數:28,代碼來源:test_directive.py

示例11: test_view_no_conflict_different_predicates

def test_view_no_conflict_different_predicates():
    app = morepath.App()

    class Model(object):
        pass

    a = app.view(model=Model, name='a', request_method='GET')
    b = app.view(model=Model, name='a', request_method='POST')

    @a
    def a_view(request, model):
        pass

    @b
    def b_view(request, model):
        pass

    c = Config()
    c.action(a, a_view)
    c.action(b, b_view)
    c.commit()
開發者ID:oohlaf,項目名稱:morepath,代碼行數:21,代碼來源:test_directive.py

示例12: test_root_no_conflict_different_apps

def test_root_no_conflict_different_apps():
    app_a = morepath.App()
    app_b = morepath.App()

    a = app_a.root()

    @a
    class Root(object):
        pass

    b = app_b.root()

    @b
    class Something(object):
        pass

    c = Config()
    c.configurable(app_a)
    c.configurable(app_b)
    c.action(a, Root)
    c.action(b, Something)
    c.commit()
開發者ID:webmaven,項目名稱:morepath,代碼行數:22,代碼來源:test_directive.py

示例13: test_root_conflict

def test_root_conflict():
    app = morepath.App()

    a = app.root()

    @a
    class Root(object):
        pass

    b = app.root()

    @b
    class Something(object):
        pass

    c = Config()
    c.configurable(app)
    c.action(a, Root)
    c.action(b, Something)

    with pytest.raises(ConflictError):
        c.commit()
開發者ID:webmaven,項目名稱:morepath,代碼行數:22,代碼來源:test_directive.py

示例14: test_view_no_conflict_different_apps

def test_view_no_conflict_different_apps():
    app_a = morepath.App()
    app_b = morepath.App()

    class Model(object):
        pass

    a = app_a.view(model=Model, name='a')
    a1 = app_b.view(model=Model, name='a')

    @a
    def a_view(request, model):
        pass

    @a1
    def a1_view(request, model):
        pass

    c = Config()
    c.configurable(app_a)
    c.configurable(app_b)
    c.action(a, a_view)
    c.action(a1, a1_view)
    c.commit()
開發者ID:webmaven,項目名稱:morepath,代碼行數:24,代碼來源:test_directive.py

示例15: test_view_conflict_with_html

def test_view_conflict_with_html():
    app = morepath.App()

    class Model(object):
        pass

    a = app.view(model=Model, name='a')
    a1 = app.html(model=Model, name='a')

    @a
    def a_view(request, model):
        pass

    @a1
    def a1_view(request, model):
        pass

    c = Config()
    c.configurable(app)
    c.action(a, a_view)
    c.action(a1, a1_view)

    with pytest.raises(ConflictError):
        c.commit()
開發者ID:webmaven,項目名稱:morepath,代碼行數:24,代碼來源:test_directive.py


注:本文中的morepath.config.Config類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。