'http://otherdomain.com/fcn' >>> filter_out('/app/ctr/fcn') '/app/ctr/fcn' >>> filter_out('/app1/ctr/fcn') '/app1/ctr/fcn' >>> filter_url('https://otherdomain.com/app1/default/fcn', out=True) '/fcn' >>> filter_url('http://otherdomain.com/app2/ctr/fcn', out=True) '/app2/ctr/fcn' >>> filter_url('http://domain1.com/app1/default/fcn?query', out=True) '/fcn?query' >>> filter_url('http://domain2.com/app3/defcon3/fcn#anchor', out=True) '/fcn#anchor' ''' pass if __name__ == '__main__': try: import gluon.main except ImportError: import sys, os os.chdir(os.path.dirname(os.path.dirname(__file__))) sys.path.append(os.path.dirname(os.path.dirname(__file__))) import gluon.main import doctest from gluon.rewrite import select, load, filter_url, filter_out, filter_err, compile_re select() # use base routing parameters load(routes=__file__) # load this file doctest.testmod()
200 >>> filter_err(399) 399 >>> filter_err(400) 400 >>> filter_url('http://domain.com/welcome', app=True) 'welcome' >>> filter_url('http://domain.com/', app=True) 'myapp' >>> filter_url('http://domain.com', app=True) 'myapp' >>> compile_re('.*http://otherdomain.com.* (?P<any>.*)', '/app/ctr\g<any>')[0].pattern '^.*http://otherdomain.com.* (?P<any>.*)$' >>> compile_re('.*http://otherdomain.com.* (?P<any>.*)', '/app/ctr\g<any>')[1] '/app/ctr\\\\g<any>' >>> compile_re('/$c/$f', '/init/$c/$f')[0].pattern '^.*?:https?://[^:/]+:[a-z]+ /(?P<c>\\\\w+)/(?P<f>\\\\w+)$' >>> compile_re('/$c/$f', '/init/$c/$f')[1] '/init/\\\\g<c>/\\\\g<f>' ''' pass if __name__ == '__main__': import gluon.main import doctest from gluon.rewrite import select, load, filter_url, filter_out, filter_err, compile_re select() load(routes=__file__) doctest.testmod()
>>> filter_err(200) 200 >>> filter_err(399) 399 >>> filter_err(400) 400 >>> filter_url('http://domain.com/welcome', app=True) 'welcome' >>> filter_url('http://domain.com/', app=True) 'myapp' >>> filter_url('http://domain.com', app=True) 'myapp' >>> compile_re('.*http://otherdomain.com.* (?P<any>.*)', '/app/ctr\g<any>')[0].pattern '^.*http://otherdomain.com.* (?P<any>.*)$' >>> compile_re('.*http://otherdomain.com.* (?P<any>.*)', '/app/ctr\g<any>')[1] '/app/ctr\\\\g<any>' >>> compile_re('/$c/$f', '/init/$c/$f')[0].pattern '^.*?:https?://[^:/]+:[a-z]+ /(?P<c>\\\\w+)/(?P<f>\\\\w+)$' >>> compile_re('/$c/$f', '/init/$c/$f')[1] '/init/\\\\g<c>/\\\\g<f>' ''' pass if __name__ == '__main__': import gluon.main import doctest from gluon.rewrite import select, load, filter_url, filter_out, filter_err, compile_re select() load(routes=__file__) doctest.testmod()
>>> filter_url('http://otherdomain.com/fcn') 'http://otherdomain.com/fcn' >>> filter_out('/app/ctr/fcn') '/app/ctr/fcn' >>> filter_out('/app1/ctr/fcn') '/app1/ctr/fcn' >>> filter_url('https://otherdomain.com/app1/default/fcn', out=True) '/fcn' >>> filter_url('http://otherdomain.com/app2/ctr/fcn', out=True) '/app2/ctr/fcn' >>> filter_url('http://domain1.com/app1/default/fcn?query', out=True) '/fcn?query' >>> filter_url('http://domain2.com/app3/defcon3/fcn#anchor', out=True) '/fcn#anchor' ''' pass if __name__ == '__main__': try: import gluon.main except ImportError: import sys, os os.chdir(os.path.dirname(os.path.dirname(__file__))) sys.path.append(os.path.dirname(os.path.dirname(__file__))) import gluon.main import doctest from gluon.rewrite import select, load, filter_url, filter_out, filter_err, compile_re select() # use base routing parameters load(routes=__file__) # load this file doctest.testmod()