def getPost(self, blogId, postId): """ Returns a post """ (created, headers) = self._makeCommonHeaders() conn = httplib.HTTPConnection(self.host) path = self.postpath % (blogId, postId) conn.request("GET", path, "", headers) response = conn.getresponse() xml = response.read() conn.close() res = [] for post in feedparser.parse(xml)['entries']: content = post['content'][0]['value'] if post['content'][0]['mode'] == 'escaped': unescape(content) thepost = Post() thepost.Title = post['title'] thepost.Created = post['modified'] thepost.ID = self.id_re.search( post['id'] ).group(1) thepost.Content = content res += [ thepost ] if res: return res[0] return None
response = conn.getresponse() except Exception,e: raise Exception("Network operation failed: "+str(e)) xml = response.read() conn.close() res = [] try: for post in feedparser.parse(xml)['entries']: content = post['content'][0]['value'] if post['content'][0]['mode'] == 'escaped': unescape(content) thepost = Post() thepost.Title = post['title'] thepost.Created = post['modified'] thepost.ID = self.id_re.search( post['id'] ).group(1) thepost.Content = content res += [ thepost ] except: raise Exception("Couldn't parse the response from the server! Bad xml?") return res def getPost(self, blogId, postId): """ Returns a post """ (created, headers) = self._makeCommonHeaders() conn = httplib.HTTPConnection(self.host) path = self.postpath % (blogId, postId) conn.request("GET", path, "", headers) response = conn.getresponse() xml = response.read() conn.close() res = []