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


Python Node.add方法代码示例

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


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

示例1: test_variable_node_more_specific_first

# 需要导入模块: from morepath.traject import Node [as 别名]
# 或者: from morepath.traject.Node import add [as 别名]
def test_variable_node_more_specific_first():
    node = Node()
    xy_node = node.add(Step('x{x}y'))
    xay_node = node.add(Step('xa{x}y'))
    ay_node = node.add(Step('a{x}y'))
    assert node.get('xwhaty') == (xy_node, {'x': 'what'})
    assert node.get('xawhaty') == (xay_node, {'x': 'what'})
    assert node.get('awhaty') == (ay_node, {'x': 'what'})
开发者ID:blaflamme,项目名称:morepath,代码行数:10,代码来源:test_traject.py

示例2: test_variable_node_optional_colon

# 需要导入模块: from morepath.traject import Node [as 别名]
# 或者: from morepath.traject.Node import add [as 别名]
def test_variable_node_optional_colon():
    node = Node()
    x_node = node.add(Step('{x}'))
    xy_node = node.add(Step('{x}:{y}'))

    variables = {}
    assert node.resolve('a', variables) is x_node
    assert variables == {'x': 'a'}

    variables = {}
    assert node.resolve('a:b', variables) is xy_node
    assert variables == {'x': 'a', 'y': 'b'}
开发者ID:morepath,项目名称:morepath,代码行数:14,代码来源:test_traject.py

示例3: test_variable_node_specific_first

# 需要导入模块: from morepath.traject import Node [as 别名]
# 或者: from morepath.traject.Node import add [as 别名]
def test_variable_node_specific_first():
    node = Node()
    x_node = node.add(Step('{x}'))

    prefix_node = node.add(Step('prefix{x}'))

    variables = {}
    assert node.resolve('what', variables) is x_node
    assert variables == {'x': 'what'}

    variables = {}
    assert node.resolve('prefixwhat', variables) is prefix_node
    assert variables == {'x': 'what'}
开发者ID:morepath,项目名称:morepath,代码行数:15,代码来源:test_traject.py

示例4: test_variable_node_more_specific_first

# 需要导入模块: from morepath.traject import Node [as 别名]
# 或者: from morepath.traject.Node import add [as 别名]
def test_variable_node_more_specific_first():
    node = Node()
    xy_node = node.add(Step('x{x}y'))
    xay_node = node.add(Step('xa{x}y'))
    ay_node = node.add(Step('a{x}y'))

    variables = {}
    assert node.resolve('xwhaty', variables) is xy_node
    assert variables == {'x': 'what'}

    variables = {}
    assert node.resolve('xawhaty', variables) is xay_node
    assert variables == {'x': 'what'}

    variables = {}
    assert node.resolve('awhaty', variables) is ay_node
    assert variables == {'x': 'what'}
开发者ID:morepath,项目名称:morepath,代码行数:19,代码来源:test_traject.py

示例5: test_name_node

# 需要导入模块: from morepath.traject import Node [as 别名]
# 或者: from morepath.traject.Node import add [as 别名]
def test_name_node():
    node = Node()
    step_node = node.add(Step('foo'))
    variables = {}
    assert node.resolve('foo', variables) is step_node
    assert not variables

    assert node.resolve('bar', variables) is None
    assert not variables
开发者ID:morepath,项目名称:morepath,代码行数:11,代码来源:test_traject.py

示例6: test_variable_node

# 需要导入模块: from morepath.traject import Node [as 别名]
# 或者: from morepath.traject.Node import add [as 别名]
def test_variable_node():
    node = Node()

    step_node = node.add(Step('{x}'))
    variables = {}
    assert node.resolve('foo', variables) is step_node
    assert variables == {'x': 'foo'}

    variables = {}
    assert node.resolve('bar', variables) is step_node
    assert variables == {'x': 'bar'}
开发者ID:morepath,项目名称:morepath,代码行数:13,代码来源:test_traject.py

示例7: test_mixed_node

# 需要导入模块: from morepath.traject import Node [as 别名]
# 或者: from morepath.traject.Node import add [as 别名]
def test_mixed_node():
    node = Node()
    step_node = node.add(Step('prefix{x}postfix'))

    variables = {}
    assert node.resolve('prefixfoopostfix', variables) is step_node
    assert variables == {'x': 'foo'}

    variables = {}
    assert node.resolve('prefixbarpostfix', variables) is step_node
    assert variables == {'x': 'bar'}

    variables = {}
    assert node.resolve('prefixwhat', variables) is None
    assert variables == {}
开发者ID:morepath,项目名称:morepath,代码行数:17,代码来源:test_traject.py

示例8: test_variable_node_specific_first

# 需要导入模块: from morepath.traject import Node [as 别名]
# 或者: from morepath.traject.Node import add [as 别名]
def test_variable_node_specific_first():
    node = Node()
    x_node = node.add(Step('{x}'))
    prefix_node = node.add(Step('prefix{x}'))
    assert node.get('what') == (x_node, {'x': 'what'})
    assert node.get('prefixwhat') == (prefix_node, {'x': 'what'})
开发者ID:blaflamme,项目名称:morepath,代码行数:8,代码来源:test_traject.py

示例9: test_mixed_node

# 需要导入模块: from morepath.traject import Node [as 别名]
# 或者: from morepath.traject.Node import add [as 别名]
def test_mixed_node():
    node = Node()
    step_node = node.add(Step('prefix{x}postfix'))
    assert node.get('prefixfoopostfix') == (step_node, {'x': 'foo'})
    assert node.get('prefixbarpostfix') == (step_node, {'x': 'bar'})
    assert node.get('prefixwhat') == (None, {})
开发者ID:blaflamme,项目名称:morepath,代码行数:8,代码来源:test_traject.py

示例10: test_variable_node

# 需要导入模块: from morepath.traject import Node [as 别名]
# 或者: from morepath.traject.Node import add [as 别名]
def test_variable_node():
    node = Node()
    step_node = node.add(Step('{x}'))
    assert node.get('foo') == (step_node, {'x': 'foo'})
    assert node.get('bar') == (step_node, {'x': 'bar'})
开发者ID:blaflamme,项目名称:morepath,代码行数:7,代码来源:test_traject.py

示例11: test_name_node

# 需要导入模块: from morepath.traject import Node [as 别名]
# 或者: from morepath.traject.Node import add [as 别名]
def test_name_node():
    node = Node()
    step_node = node.add(Step('foo'))
    assert node.get('foo') == (step_node, {})
    assert node.get('bar') == (None, {})
开发者ID:blaflamme,项目名称:morepath,代码行数:7,代码来源:test_traject.py

示例12: test_variable_node_optional_colon

# 需要导入模块: from morepath.traject import Node [as 别名]
# 或者: from morepath.traject.Node import add [as 别名]
def test_variable_node_optional_colon():
    node = Node()
    x_node = node.add(Step("{x}"))
    xy_node = node.add(Step("{x}:{y}"))
    assert node.get("a") == (x_node, {"x": "a"})
    assert node.get("a:b") == (xy_node, {"x": "a", "y": "b"})
开发者ID:reinout,项目名称:morepath,代码行数:8,代码来源:test_traject.py


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