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


Python Config.action方法代码示例

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


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

示例1: test_path_conflict_with_variable

# 需要导入模块: from morepath.config import Config [as 别名]
# 或者: from morepath.config.Config import action [as 别名]
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,代码行数:30,代码来源:test_directive.py

示例2: test_model_no_conflict_different_apps

# 需要导入模块: from morepath.config import Config [as 别名]
# 或者: from morepath.config.Config import action [as 别名]
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,代码行数:28,代码来源:test_directive.py

示例3: test_function_conflict

# 需要导入模块: from morepath.config import Config [as 别名]
# 或者: from morepath.config.Config import action [as 别名]
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,代码行数:30,代码来源:test_directive.py

示例4: test_function_no_conflict_different_apps

# 需要导入模块: from morepath.config import Config [as 别名]
# 或者: from morepath.config.Config import action [as 别名]
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,代码行数:29,代码来源:test_directive.py

示例5: test_model_conflict

# 需要导入模块: from morepath.config import Config [as 别名]
# 或者: from morepath.config.Config import action [as 别名]
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,代码行数:27,代码来源:test_directive.py

示例6: test_no_path_conflict_with_variable_different_converters

# 需要导入模块: from morepath.config import Config [as 别名]
# 或者: from morepath.config.Config import action [as 别名]
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,代码行数:29,代码来源:test_directive.py

示例7: test_view_predicates

# 需要导入模块: from morepath.config import Config [as 别名]
# 或者: from morepath.config.Config import action [as 别名]
def test_view_predicates():
    setup()

    app = App()

    class Root(object):
        pass

    def get(request, model):
        return 'GET'

    def post(request, model):
        return 'POST'

    c = Config()
    c.action(app, app)
    c.action(app.root(), Root)
    c.action(app.view(model=Root, name='foo', request_method='GET'),
             get)
    c.action(app.view(model=Root, name='foo', request_method='POST'),
             post)

    c.commit()

    c = Client(app, Response)

    response = c.get('/foo')
    assert response.data == 'GET'
    response = c.post('/foo')
    assert response.data == 'POST'
开发者ID:kingel,项目名称:morepath,代码行数:32,代码来源:test_predicates.py

示例8: test_imperative

# 需要导入模块: from morepath.config import Config [as 别名]
# 或者: from morepath.config.Config import action [as 别名]
def test_imperative():
    setup()

    class Foo(object):
        pass

    @reg.generic
    def target():
        pass

    app = App()

    c = Config()
    c.action(app, app)
    foo = Foo()
    c.action(app.function(target), foo)
    c.commit()

    assert target.component(lookup=app.lookup()) is foo
开发者ID:kingel,项目名称:morepath,代码行数:21,代码来源:test_directive.py

示例9: test_root_no_conflict_different_apps

# 需要导入模块: from morepath.config import Config [as 别名]
# 或者: from morepath.config.Config import action [as 别名]
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.action(a, Root)
    c.action(b, Something)
    c.commit()
开发者ID:oohlaf,项目名称:morepath,代码行数:22,代码来源:test_directive.py

示例10: test_view_no_conflict_different_predicates

# 需要导入模块: from morepath.config import Config [as 别名]
# 或者: from morepath.config.Config import action [as 别名]
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,代码行数:23,代码来源:test_directive.py

示例11: test_root_conflict

# 需要导入模块: from morepath.config import Config [as 别名]
# 或者: from morepath.config.Config import action [as 别名]
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.action(a, Root)
    c.action(b, Something)

    with pytest.raises(ConflictError):
        c.commit()
开发者ID:oohlaf,项目名称:morepath,代码行数:23,代码来源:test_directive.py

示例12: test_json_directive

# 需要导入模块: from morepath.config import Config [as 别名]
# 或者: from morepath.config.Config import action [as 别名]
def test_json_directive():
    setup()

    app = morepath.App()

    class Model(object):
        def __init__(self, id):
            self.id = id

    def default(request, model):
        return "The view for model: %s" % model.id

    def json(request, model):
        return {'id': model.id}

    c = Config()
    c.action(app, app)
    c.action(app.model(path='{id}',
                       variables=lambda model: {'id': model.id}),
             Model)
    c.action(app.json(model=Model),
             json)
    c.commit()

    c = Client(app, Response)

    response = c.get('/foo')
    assert response.data == '{"id": "foo"}'
开发者ID:kingel,项目名称:morepath,代码行数:30,代码来源:test_directive.py

示例13: test_view_no_conflict_different_names

# 需要导入模块: from morepath.config import Config [as 别名]
# 或者: from morepath.config.Config import action [as 别名]
def test_view_no_conflict_different_names():
    app = morepath.App()

    class Model(object):
        pass

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

    @a
    def a_view(request, model):
        pass

    @b
    def b_view(request, model):
        pass

    c = Config()
    c.configurable(app)
    c.action(a, a_view)
    c.action(b, b_view)
    c.commit()
开发者ID:webmaven,项目名称:morepath,代码行数:24,代码来源:test_directive.py

示例14: test_view_no_conflict_different_apps

# 需要导入模块: from morepath.config import Config [as 别名]
# 或者: from morepath.config.Config import action [as 别名]
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.action(a, a_view)
    c.action(a1, a1_view)
    c.commit()
开发者ID:oohlaf,项目名称:morepath,代码行数:24,代码来源:test_directive.py

示例15: test_view_conflict_with_html

# 需要导入模块: from morepath.config import Config [as 别名]
# 或者: from morepath.config.Config import action [as 别名]
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.action(a, a_view)
    c.action(a1, a1_view)

    with pytest.raises(ConflictError):
        c.commit()
开发者ID:oohlaf,项目名称:morepath,代码行数:25,代码来源:test_directive.py


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