Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
## original def _fetch(self, uri, post_args, **url_args): url_args["format"] = "json" args = urllib.urlencode(url_args) url = "http://friendfeed.com" + uri + "?" + args if post_args is not None: request = urllib2.Request(url, urllib.urlencode(post_args)) else: request = urllib2.Request(url) if self.auth_nickname and self.auth_key: pair = "%s:%s" % (self.auth_nickname, self.auth_key) token = base64.b64encode(pair) request.add_header("Authorization", "Basic %s" % token) stream = urllib2.urlopen(request) data = stream.read() stream.close() return parse_json(data) ## modified for app-engine def _fetch(self, uri, post_args, **url_args): url_args["format"] = "json" args = urllib.urlencode(url_args) url = "http://friendfeed.com" + uri + "?" + args headers = {} if post_args is not None: post_data = urllib.urlencode(post_args) method = "POST" headers={'Content-Type': 'application/x-www-form-urlencoded'} else: post_data = None method = "GET" if self.auth_nickname and self.auth_key: pair = "%s:%s" % (self.auth_nickname, self.auth_key) token = base64.b64encode(pair) headers["Authorization"] = "Basic %s" % token result = urlfetch.fetch(url=url, payload=post_data, method=method, headers=headers) data = result.content self.result = result self.feed_json = data return parse_json(data)
This paste will be private.
From the Design Piracy series on my blog: