forked from pypi/legacy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
oic.py
36 lines (26 loc) · 929 Bytes
/
oic.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from authomatic.adapters import BaseAdapter
import urlparse
import Cookie
class PyPIAdapter(BaseAdapter):
def __init__(self, env, config, handler, form):
self.env = env
self.config = config
self.handler = handler
self.form = form
@property
def params(self):
return dict(self.form)
@property
def url(self):
parse = urlparse.urlparse(self.config.url)
return urlparse.urlunparse(parse._replace(path="pypi", query=":action=openid_return"))
@property
def cookies(self):
return dict([(k, v.value) for k, v in Cookie.SimpleCookie(self.env.get('HTTP_COOKIE', '')).items()])
def write(self, value):
self.response.end_headers()
self.handler.wfile.write(value)
def set_header(self, key, value):
self.handler.send_header(key, value)
def set_status(self, status):
self.handler.set_status(status)