web/test/unittest_views_apacherewrite.py
branchstable
changeset 2172 cf8f9180e63e
parent 2000 bcb9a55a89e0
child 4212 ab6573088b4a
equal deleted inserted replaced
2125:19861294506f 2172:cf8f9180e63e
    10 from cubicweb.web.views.apacherewrite import *
    10 from cubicweb.web.views.apacherewrite import *
    11 
    11 
    12 class ApacheURLRewriteTC(TestCase):
    12 class ApacheURLRewriteTC(TestCase):
    13 
    13 
    14     def test(self):
    14     def test(self):
    15         class MyAppRules(ApacheURLRewrite): 
    15         class MyAppRules(ApacheURLRewrite):
    16             rules = [
    16             rules = [
    17                 RewriteCond('logilab\.fr', match='host',
    17                 RewriteCond('logilab\.fr', match='host',
    18                             rules=[('/(.*)', r'http://www.logilab.fr/\1')],
    18                             rules=[('/(.*)', r'http://www.logilab.fr/\1')],
    19                             action='redirect'),
    19                             action='redirect'),
    20                 RewriteCond('(www)\.logilab\.fr', match='host', action='stop'),
    20                 RewriteCond('(www)\.logilab\.fr', match='host', action='stop'),
    21                 RewriteCond('/(data|json)/', match='path', action='stop'),
    21                 RewriteCond('/(data|json)/', match='path', action='stop'),
    22                 RewriteCond('(?P<cat>.*)\.logilab\.fr', match='host', 
    22                 RewriteCond('(?P<cat>.*)\.logilab\.fr', match='host',
    23                             rules=[('/(.*)', r'/m_%(cat)s/\1')]),
    23                             rules=[('/(.*)', r'/m_%(cat)s/\1')]),
    24                 ]
    24                 ]
    25         urlrewriter = MyAppRules()
    25         urlrewriter = MyAppRules()
    26         req = None # not used in the above rules, so keep a simple TestCase here
    26         req = None # not used in the above rules, so keep a simple TestCase here
    27         try:
    27         try: