1
0
mirror of https://github.com/webrecorder/pywb.git synced 2025-03-15 00:03:28 +01:00

cleanup, setup runnable testwb, or pluggable 'globalwb'

This commit is contained in:
Ilya Kreymer 2014-01-04 00:21:52 +00:00
parent c3767cd31b
commit 246b3fba43
5 changed files with 32 additions and 27 deletions

View File

@ -51,7 +51,7 @@ class RemoteCDXServer:
return response
@staticmethod
def getQueryParams(wburl, limit = '150000', collapseTime = '10', replayClosest = '200'):
def getQueryParams(wburl, limit = '150000', collapseTime = '10', replayClosest = '4000'):
return {
ArchivalUrl.QUERY:

View File

@ -24,4 +24,14 @@ class QueryHandler:
raise wbexceptions.NotFoundException('WB Does Not Have Url: ' + wburl.url)
## ===========
## Simple handlers for debuging
class EchoEnv:
def __call__(self, wbrequest, _):
return WbResponse.text_response(str(wbrequest.env))
class EchoRequest:
def __call__(self, wbrequest, _):
return WbResponse.text_response(str(wbrequest))

View File

@ -1,27 +1,14 @@
from query import QueryHandler
from query import QueryHandler, EchoEnv, EchoRequest
from replay import FullHandler
import wbexceptions
import indexreader
from wbrequestresponse import WbResponse, StatusAndHeaders
from archivalrouter import ArchivalRequestRouter
## ===========
class EchoEnv:
def __call__(self, wbrequest, _):
return WbResponse.text_response(str(wbrequest.env))
class WBHandler:
def __call__(self, wbrequest, _):
return WbResponse.text_response(str(wbrequest))
## ===========
import testwb
query = QueryHandler(testwb.createCdxServer())
headInsert = """
<!-- WB Insert -->
@ -30,26 +17,36 @@ headInsert = """
<!-- End WB Insert -->
"""
replay = testwb.createReplay(headInsert)
## ===========
parser = ArchivalRequestRouter(
def createDefaultWB(headInsert):
query = QueryHandler(indexreader.RemoteCDXServer('http://web.archive.org/cdx/search/cdx'))
return ArchivalRequestRouter(
{
't0' : [EchoEnv()],
't1' : [WBHandler()],
't2' : [query],
't3' : [query, replay],
'web': FullHandler(query, replay)
'echo' : [EchoEnv()],
'req' : [EchoRequest()],
'cdx' : [query],
'web' : [query],
},
hostpaths = ['http://localhost:9090/'])
## ===========
try:
import globalwb
wbparser = globalwb.createDefaultWB(headInsert)
except:
print " *** Test Wayback Inited *** "
wbparser = createDefaultWB(headInsert)
def application(env, start_response):
response = None
try:
response = parser.handleRequest(env)
response = wbparser.handleRequest(env)
if not response:
raise wbexceptions.NotFoundException(env['REQUEST_URI'] + ' was not found')

View File

@ -11,7 +11,7 @@ setuptools.setup(name='pywb',
long_description=open('README.md').read(),
license='GPL',
packages=['pywb'],
install_requires=['rfc3987', 'chardet', 'redis'],
install_requires=['uwsgi', 'rfc3987', 'chardet', 'redis'],
# test_suite='?', # not sure how to run doctests here
zip_safe=False)

View File

@ -23,8 +23,6 @@ function initBanner()
if (!banner) {
banner = document.createElement("wb_div");
banner.setAttribute("id", BANNER_ID);
banner.style.cssText = "display: block; width: 100%; border: 1px solid; background-color: lightYellow; text-align: center";
banner.innerHTML = "PyWb Test Banner!"
document.body.insertBefore(banner, document.body.firstChild);
}