def __init__(self, feed_id, title, link, uuid, content, published, author=None, comments=None, created=None): content = html_sanitizer(content) self.feed_id = feed_id self.title = title self.link = link self.uuid = uuid self.content = content self.content_hash = Entry.hash_content(content) self.published = published self.author = author self.comments = comments self.created = created if created is not None else datetime.datetime.now()
def sanitizer(): entries = Entry.query.all() for entry in entries: print "========================" print "Original:" print "========================" print entry.content_hash print entry.content result = html_sanitizer(entry.content) print "========================" print "Cleaned:" print "========================" print result entry.content = result entry.content_hash = Entry.hash_content(result) db.session.add(entry) db.session.commit()