Skip to content
Browse files

Drop httplib2 in favour of urllib so as to reduce external dependencies

  • Loading branch information...
1 parent c8437a7 commit e6d56da089ad33e7c365605c9c5ca5fc99f07faf Toby White committed Jul 8, 2010
Showing with 5 additions and 6 deletions.
  1. +5 −6 gmail.py
View
11 gmail.py
@@ -35,8 +35,6 @@ def verify_signature(self, msg, signature):
class Connection(object):
def __init__(self, EMAIL_APPENGINE_PROXY_URL=None):
- import httplib2
- self.h = httplib2.Http()
if not EMAIL_APPENGINE_PROXY_URL:
try:
EMAIL_APPENGINE_PROXY_URL = os.environ['GMAIL_PROXY_URL']
@@ -48,7 +46,8 @@ def __init__(self, EMAIL_APPENGINE_PROXY_URL=None):
self.EMAIL_APPENGINE_PROXY_URL = EMAIL_APPENGINE_PROXY_URL
def make_request(self, data):
- return self.h.request(self.EMAIL_APPENGINE_PROXY_URL, "POST", body=data)
+ response = urllib.urlopen(self.EMAIL_APPENGINE_PROXY_URL, data=data)
+ return response.getcode(), response.read()
class GmailProxy(object):
@@ -61,10 +60,10 @@ def send_mail(self, msg):
values = {'msg':msg.as_string(),
'signature':self.signer.generate_signature(msg.as_string())}
data = urllib.urlencode([(k, v.encode('utf-8')) for k, v in values.items()])
- r, c = self.connection.make_request(data)
+ status, errmsg = self.connection.make_request(data)
- if r.status != 204 and not self.fail_silently:
- raise MessageSendingFailure(c)
+ if status != 204 and not self.fail_silently:
+ raise MessageSendingFailure(errmsg)
if __name__ == '__main__':

0 comments on commit e6d56da

Please sign in to comment.
Something went wrong with that request. Please try again.