示例#1
0
def get_matching_app(settings):
    static_app = DirectoryApp(settings['weiwei.static'])
    static_matching = m('/static/*path', static_app, name='static')
    matching = bundle(
        static_matching,
        include('', web_matching),
    )
    return make_wsgi_app(matching)
示例#2
0
from matcha import Matching as m
from matcha import include, bundle


about_pages = bundle(
    m('/htt/', 'htt', 'about_htt'),
    m('/activity/*activity', 'activity', 'about_activity')
)

member_pages = bundle(
    m('/', 'member_list', 'member_list'),
    m('/{member}/', 'member_detail', 'member_detail'),
)

matching = bundle(
    m('/', 'home', 'home'),
    include('/about/', about_pages),
    include('/member/', member_pages),
)


def test_it():
    assert matching['/'] == ('home', {})
    assert matching['/about/htt/'] == ('htt', {})
    assert matching['/about/activity/outdoor_fes/2013/winter'] == \
        ('activity', {'activity': ['outdoor_fes', '2013', 'winter']})
    assert matching['/member/'] == ('member_list', {})
    assert matching['/member/ritsu/'] == ('member_detail', {'member': 'ritsu'})