web/views/apacherewrite.py
branchtls-sprint
changeset 661 4f61eb8a96b7
parent 0 b97547f5f1fa
child 1802 d628defebc17
equal deleted inserted replaced
660:5233a9457f6b 661:4f61eb8a96b7
     1 """provide class to do Apache rewrite rules'job inside cubicweb (though functionnalities
     1 """provide class to do Apache rewrite rules'job inside cubicweb (though functionnalities
     2 are much more limited for the moment)
     2 are much more limited for the moment)
     3 
     3 
     4 :organization: Logilab
     4 :organization: Logilab
     5 :copyright: 2007-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     5 :copyright: 2007-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     6 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
     6 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
     7 """
     7 """
     8 
     8 
     9 __docformat__ = "restructuredtext en"
     9 __docformat__ = "restructuredtext en"
    10 
    10 
    11 from re import compile
    11 from re import compile
    12 
    12 
    13 from cubicweb.web import Redirect
    13 from cubicweb.web import Redirect
    14 from cubicweb.web.component import SingletonComponent
    14 from cubicweb.web.component import Component
    15 
    15 
    16 class RewriteCond(object):
    16 class RewriteCond(object):
    17     def __init__(self, condition, match='host', rules=(), action='rewrite'):
    17     def __init__(self, condition, match='host', rules=(), action='rewrite'):
    18         self.condition = compile(condition)
    18         self.condition = compile(condition)
    19         assert match in ('host', 'path'), match
    19         assert match in ('host', 'path'), match
    44 
    44 
    45     def action_stop(self, path):
    45     def action_stop(self, path):
    46         return path
    46         return path
    47 
    47 
    48     
    48     
    49 class ApacheURLRewrite(SingletonComponent):
    49 class ApacheURLRewrite(Component):
    50     """inherit from this class with actual rules to activate apache style rewriting
    50     """inherit from this class with actual rules to activate apache style rewriting
    51 
    51 
    52     rules should have the form :
    52     rules should have the form :
    53 
    53 
    54     [('condition pattern 1', [('rule1 pattern', 'replace expression'),
    54     [('condition pattern 1', [('rule1 pattern', 'replace expression'),