def badRequest(message): yield httputils.badRequestHtml yield '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">\n' yield "<html><head>\n" yield "<title>400 Bad Request</title>\n" yield "</head><body>\n" yield "<h1>Not Found</h1>\n" yield "<!-- %s -->\n" % htmlEscape(str(message)) yield "</body></html>\n"
def convertToGaeDatatype(instance, property, value): if isinstance(getattr(instance,property), datetime): return iso8601.parse_date(value) elif isinstance(getattr(instance,property), User): return User(value) elif isinstance(getattr(instance,property), Model): return Key(value) elif isinstance(getattr(instance,property), str): return htmlEscape(value) else: return value
def write(self, s): # reject non-shortest-form encodings, which might defeat the escaping s.decode('utf-8', 'strict') self.request.write(htmlEscape(s)) if self.tee: self.tee.write(s)
def getFileDescription(i): name = fileNames[i] subject = open(name).readline() return '%s <i>(%s)</i>' % (htmlEscape(subject), htmlEscape(name.split('/')[-1]))
(bug.get('id'))) # retrieve bug comments comment_payload = { 'method': 'Bug.comments', 'params': json.dumps([{ 'ids': ['%s' % bug.get('id')] }]) } comments = bingle.getBugComments(comment_payload, bug.get('id')) link = '<br><p>Full bug report at https://bugzilla.wikimedia.org/%s' \ '</p>' % bug.get('id') # set common mingle parameters description = htmlEscape( comments.get('comments')[0].get('text')).replace("\n", "<br />") + link cardParams = { 'card[name]': bugCardName, 'card[card_type_name]': bugCard, 'card[description]': description, 'card[created_by]': auth['username'], } cardLocation = mingle.addCard(cardParams) bingle.info(mingle.dumpRequest()) postComments(auth, apiBaseUrl, comments, cardLocation) # set custom mingle properties
bug.get('id'))) continue else: bingle.info('Did not find card matching bug %s, so add it.' % (bug.get('id'))) # retrieve bug comments comment_payload = {'method': 'Bug.comments', 'params': json.dumps( [{'ids': ['%s' % bug.get('id')]}])} comments = bingle.getBugComments(comment_payload, bug.get('id')) link = '<br><p>Full bug report at https://bugzilla.wikimedia.org/%s' \ '</p>' % bug.get('id') # set common mingle parameters description = htmlEscape( comments.get('comments')[0].get('text')).replace( "\n", "<br />") + link cardParams = { 'card[name]': bugCardName, 'card[card_type_name]': bugCard, 'card[description]': description, 'card[created_by]': auth['username'], } cardLocation = mingle.addCard(cardParams) bingle.info(mingle.dumpRequest()) postComments(auth, apiBaseUrl, comments, cardLocation) # set custom mingle properties