obsoleted exception when parsing new entries

This commit is contained in:
Ronald Schaten 2013-03-21 22:38:44 +01:00
parent d3cb933521
commit 53c4665c85

View File

@ -250,16 +250,17 @@ def fetch_full_page(link):
return text.encode('latin-1', 'replace') return text.encode('latin-1', 'replace')
def process_feed_entry(session, feed, entry): def process_feed_entry(session, feed, entry):
#query = session.query(Entry).filter_by(feed_id=feed.id, title=entry.title.encode('latin-1', 'replace')) thisentry = session.query(Entry).\
title = entry.title.encode('latin-1', 'replace') filter(Entry.feed_id == feed.id).\
link = entry.link.encode('latin-1', 'replace') filter(Entry.title == entry.title).\
query = session.query(Entry).filter(Entry.feed_id==feed.id).filter(Entry.title==title).filter(Entry.link==link) filter(Entry.link == entry.link).\
try: first()
thisentry = query.one() if thisentry:
thisentry.update(entry)
print ' entry already known <%s>' % entry.title print ' entry already known <%s>' % entry.title
thisentry.lastfetched = datetime.now()
session.commit()
return 0 return 0
except Exception, e: else:
print ' new entry <%s>' % entry.title print ' new entry <%s>' % entry.title
thisentry = Entry(entry) thisentry = Entry(entry)
if feed.resolveredirects: if feed.resolveredirects:
@ -283,8 +284,9 @@ def process_feed_entry(session, feed, entry):
h2t.ignore_images = True h2t.ignore_images = True
summary = thisentry.summary.decode('latin-1') summary = thisentry.summary.decode('latin-1')
summary = h2t.handle(summary) summary = h2t.handle(summary)
thisentry.summary = summary.encode('latin-1', 'replace') thisentry.summary = summary.encode('latin-1')
feed.entry.append(thisentry) feed.entry.append(thisentry)
session.commit()
return 1 return 1
def fetch_single_feed(session, feed): def fetch_single_feed(session, feed):