Skip to content
This repository has been archived by the owner on Dec 4, 2019. It is now read-only.

Commit

Permalink
Drop httplib2 in favour of urllib so as to reduce external dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Toby White committed Jul 8, 2010
1 parent c8437a7 commit e6d56da
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions gmail.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand All @@ -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):
Expand All @@ -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__':
Expand Down

0 comments on commit e6d56da

Please sign in to comment.