Fix hook call and cleaning

* mandaye/dispatchers/default.py: fix hook call
This commit is contained in:
Jérôme Schneider 2011-09-06 19:35:15 +02:00
parent fff050a09b
commit 2b114abe74
4 changed files with 21 additions and 20 deletions

View File

@ -17,16 +17,18 @@ class Dispatcher(object):
"""
self.target = urlparse(target_url)
self.env = None
self.mapping = None
self.mapping = mapping
def init(self, env):
self.env = env
self.env['target'] = self.target
self.filter = MandayeFilter(self.env, self.target)
if self.mapping['PATH_INFO'] and \
self.mapping['PATH_INFO'].has_key('method') and \
self.mapping['PATH_INFO']['method'] == self.env['REQUEST_METHOD']:
self.req_mapping = self.mapping['PATH_INFO']
path = self.env['PATH_INFO']
if self.mapping and \
self.mapping.has_key(path) and \
self.mapping[path].has_key('method') and \
self.mapping[path]['method'] == self.env['REQUEST_METHOD']:
self.req_mapping = self.mapping[path]
else:
self.req_mapping = None

View File

@ -42,20 +42,22 @@ class AuthFormDispatcher(Dispatcher):
#self.local_auth = LocalAuthForm(self.target)
#self.dest_auth = DestAuthForm(self.target)
def login(self, request):
def login(self, values):
from mandaye.response import _502
return _502
#id = self.local_auth.get_current_user():
action = "/sezhame/page/connexion-abonne"
#action = "/sezhame/page/connexion-abonne"
#url = 'http://biblio.vincennes.fr/sezhame/page/connexion-abonne'
params = urllib.urlencode(values)
params = 'user=754443&password=lecteur&op=Se+connecter&form_id=dk_opac15_login_form'
headers = { 'Content-Type': 'application/x-www-form-urlencoded',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Cookie': request.cookies.output(header="", sep=",")
}
conn = httplib.HTTPConnection(self.target.hostname)
conn.request("POST", action, params, headers)
res = conn.getresponse()
conn.close()
#params = urllib.urlencode(values)
#params = 'user=754443&password=lecteur&op=Se+connecter&form_id=dk_opac15_login_form'
#headers = { 'Content-Type': 'application/x-www-form-urlencoded',
# 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
# 'Cookie': request.cookies.output(header="", sep=",")
# }
#conn = httplib.HTTPConnection(self.target.hostname)
#conn.request("POST", action, params, headers)
#res = conn.getresponse()
#conn.close()
def connection(self, request, response):
pass

View File

@ -54,11 +54,9 @@ class MandayeFilter(object):
blacklist = ['transfer-encoding']
for key, value in headers.iteritems():
if key == 'location':
print headers['location']
location = value[0].replace(self.target.hostname,
self.env["HTTP_HOST"])
headers.addheader(key, location)
print headers['location']
for name in blacklist:
if headers.has_key(name):
del headers[name]

View File

@ -66,7 +66,6 @@ class MandayeApp(object):
headers.addheader(name, value)
if self.env.has_key('HTTP_COOKIE'):
print self.env['HTTP_COOKIE']
cookies = Cookie.BaseCookie(self.env['HTTP_COOKIE'])
else:
cookies = Cookie.BaseCookie()