fixed problem with pg8000 diver import, thanks Alan

This commit is contained in:
Massimo DiPierro
2012-03-11 19:38:46 -05:00
parent 8ac7656f2d
commit b14b006946
3 changed files with 19 additions and 9 deletions
+1 -1
View File
@@ -1 +1 @@
Version 1.99.7 (2012-03-09 13:49:42) dev Version 1.99.7 (2012-03-11 19:38:42) dev
+13 -5
View File
@@ -105,7 +105,6 @@ class OAuthAccount(object):
redirect_uri=current.session.redirect_uri, redirect_uri=current.session.redirect_uri,
response_type='token', code=current.session.code) response_type='token', code=current.session.code)
if self.args: if self.args:
data.update(self.args) data.update(self.args)
open_url = None open_url = None
@@ -113,22 +112,27 @@ class OAuthAccount(object):
try: try:
open_url = opener.open(self.token_url, urlencode(data)) open_url = opener.open(self.token_url, urlencode(data))
except urllib2.HTTPError, e: except urllib2.HTTPError, e:
raise Exception(e.read()) tmp = e.read()
print tmp
raise Exception(tmp)
finally: finally:
del current.session.code # throw it away del current.session.code # throw it away
if open_url: if open_url:
try: try:
tokendata = cgi.parse_qs(open_url.read()) data = open_url.read()
tokendata = cgi.parse_qs(data)
current.session.token = \ current.session.token = \
dict([(k,v[-1]) for k,v in tokendata.items()]) dict([(k,v[-1]) for k,v in tokendata.items()])
# set expiration absolute time try to avoid broken # set expiration absolute time try to avoid broken
# implementations where "expires_in" becomes "expires" # implementations where "expires_in" becomes "expires"
if current.session.token.has_key('expires_in'): if current.session.token.has_key('expires_in'):
exps = 'expires_in' exps = 'expires_in'
else: elif current.session.token.has_key('expires'):
exps = 'expires' exps = 'expires'
current.session.token['expires'] = \ else:
exps = None
current.session.token['expires'] = exps and \
int(current.session.token[exps]) + \ int(current.session.token[exps]) + \
time.time() time.time()
finally: finally:
@@ -161,6 +165,10 @@ class OAuthAccount(object):
""" """
Returns the user using the Graph API. Returns the user using the Graph API.
""" """
if not current.session.token: return None
return dict(first_name = 'Pinco',
last_name = 'Pallino',
username = 'pincopallino')
raise NotImplementedError, "Must override get_user()" raise NotImplementedError, "Must override get_user()"
if not self.accessToken(): if not self.accessToken():
return None return None
+5 -3
View File
@@ -1993,10 +1993,12 @@ class PostgreSQLAdapter(BaseAdapter):
% (db, user, host, port, password) % (db, user, host, port, password)
# choose diver according uri # choose diver according uri
if library == "postgres": if library == "postgres":
if self.drivers.get('psycopg2'): if 'psycopg2' in self.drivers:
self.driver = self.drivers['psycopg2'] self.driver = self.drivers['psycopg2']
elif self.drivers.get('pg8000'): elif 'pg8000' in self.drivers:
self.driver = drivers.get('pg8000') self.driver = self.drivers['pg8000']
else:
raise RuntimeError, "No pgsql driver"
elif library == "postgres:psycopg2": elif library == "postgres:psycopg2":
self.driver = self.drivers.get('psycopg2') self.driver = self.drivers.get('psycopg2')
elif library == "postgres:pg8000": elif library == "postgres:pg8000":