本文整理汇总了Python中morepath.traject.Traject.path方法的典型用法代码示例。如果您正苦于以下问题:Python Traject.path方法的具体用法?Python Traject.path怎么用?Python Traject.path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类morepath.traject.Traject
的用法示例。
在下文中一共展示了Traject.path方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_path_for_model
# 需要导入模块: from morepath.traject import Traject [as 别名]
# 或者: from morepath.traject.Traject import path [as 别名]
def test_path_for_model():
traject = Traject()
class IdModel(object):
def __init__(self, id):
self.id = id
traject.inverse(IdModel, "foo/{id}", lambda model: {"id": model.id}, {}, [])
assert traject.path(IdModel("a")) == ("foo/a", {})
示例2: test_path_for_model_with_converter
# 需要导入模块: from morepath.traject import Traject [as 别名]
# 或者: from morepath.traject.Traject import path [as 别名]
def test_path_for_model_with_converter():
traject = Traject()
class IdModel(object):
def __init__(self, id):
self.id = id
traject.inverse(IdModel, "foo/{id}", lambda model: {"id": model.id}, dict(id=Converter(int)), [])
assert traject.path(IdModel(1)) == ("foo/1", {})
示例3: test_path_for_model_with_converter
# 需要导入模块: from morepath.traject import Traject [as 别名]
# 或者: from morepath.traject.Traject import path [as 别名]
def test_path_for_model_with_converter():
traject = Traject()
class IdModel(object):
def __init__(self, id):
self.id = id
traject.inverse(IdModel, 'foo/{id:int}',
lambda model: {'id': model.id})
assert traject.path(IdModel(1)) == 'foo/1'
示例4: test_path_for_model
# 需要导入模块: from morepath.traject import Traject [as 别名]
# 或者: from morepath.traject.Traject import path [as 别名]
def test_path_for_model():
traject = Traject()
class IdModel(object):
def __init__(self, id):
self.id = id
traject.inverse(IdModel, 'foo/{id}',
lambda model: {'id': model.id},
{}, [])
assert traject.path(IdModel('a')) == ('foo/a', {})