mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-24 06:59:52 +01:00
framework/urlrewriter: allow overriding UrlRewriter with optional urlrewriter_class param,
easier to override create_rebased_rewriter() with custom rewriter as well
This commit is contained in:
parent
dcf3688dc3
commit
79cfdd6a08
@ -23,6 +23,9 @@ class ArchivalRouter(object):
|
|||||||
self.home_view = kwargs.get('home_view')
|
self.home_view = kwargs.get('home_view')
|
||||||
self.error_view = kwargs.get('error_view')
|
self.error_view = kwargs.get('error_view')
|
||||||
|
|
||||||
|
self.urlrewriter_class = (kwargs.get('config', {}).
|
||||||
|
get('urlrewriter_class', UrlRewriter))
|
||||||
|
|
||||||
def __call__(self, env):
|
def __call__(self, env):
|
||||||
request_uri = env['REL_REQUEST_URI']
|
request_uri = env['REL_REQUEST_URI']
|
||||||
|
|
||||||
@ -61,7 +64,7 @@ class ArchivalRouter(object):
|
|||||||
coll=coll,
|
coll=coll,
|
||||||
use_abs_prefix=use_abs_prefix,
|
use_abs_prefix=use_abs_prefix,
|
||||||
wburl_class=route.handler.get_wburl_type(),
|
wburl_class=route.handler.get_wburl_type(),
|
||||||
urlrewriter_class=UrlRewriter,
|
urlrewriter_class=self.urlrewriter_class,
|
||||||
cookie_scope=route.cookie_scope,
|
cookie_scope=route.cookie_scope,
|
||||||
rewrite_opts=route.rewrite_opts)
|
rewrite_opts=route.rewrite_opts)
|
||||||
|
|
||||||
|
@ -90,7 +90,10 @@ class UrlRewriter(object):
|
|||||||
new_url = new_url[len(self.prefix):]
|
new_url = new_url[len(self.prefix):]
|
||||||
|
|
||||||
new_wburl = WbUrl(new_url)
|
new_wburl = WbUrl(new_url)
|
||||||
return UrlRewriter(new_wburl, self.prefix)
|
return self._create_rebased_rewriter(new_wburl, self.prefix)
|
||||||
|
|
||||||
|
def _create_rebased_rewriter(self, new_wburl, prefix):
|
||||||
|
return UrlRewriter(new_wburl, prefix)
|
||||||
|
|
||||||
def get_cookie_rewriter(self, scope=None):
|
def get_cookie_rewriter(self, scope=None):
|
||||||
# collection scope overrides rule scope?
|
# collection scope overrides rule scope?
|
||||||
|
Loading…
x
Reference in New Issue
Block a user