From: Eric S. Raymond Date: Sun, 17 Oct 2010 19:31:52 +0000 (-0400) Subject: Method override that works. X-Git-Tag: 2.0~9 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=82776f00f67dcebe5c5f54fb5745dd51265febac;p=freecode-submit.git Method override that works. --- diff --git a/freshmeat-submit b/freshmeat-submit index 55e4036..ddeafbc 100755 --- a/freshmeat-submit +++ b/freshmeat-submit @@ -27,10 +27,16 @@ class Update: class RequestWithMethod(urllib2.Request): "Hack for forcing the method in a request - allows PUT and DELETE" - # Method lifted from http://benjamin.smedbergs.us/blog/2008-10-21/putting-and-deleteing-in-python-urllib2/ def __init__(self, method, *args, **kwargs): - self._method = method + self.method = method urllib2.Request.__init__(self, *args, **kwargs) + def get_method(self): + if self.method: + return self.method + elif self.has_data(): + return "POST" + else: + return "GET" class FreshmeatSessionException: def __init__(self, msg): @@ -38,7 +44,7 @@ class FreshmeatSessionException: class FreshmeatSession: "Encapsulate the state of a Freshmeat API session." - server = "http://freshmeat.net/" + server = "http://staging.freshmeat3.net/" def __init__(self, auth=None, verbose=0, emit_enable=True): "Initialize Freshmeat session credentials."