Mercurial > hg > Feedworm
comparison feedupdate-main.py @ 4:e0199f383442
retrieve a feed for the given URL, store entries as feed_entry rows into the database
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Mon, 26 Apr 2010 19:33:07 +0200 |
parents | 8a624ee48a74 |
children | bfd47f55d85b |
comparison
equal
deleted
inserted
replaced
3:2ac144a98370 | 4:e0199f383442 |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 from ConfigParser import ConfigParser | 3 from ConfigParser import ConfigParser |
4 from Feed import Feed | 4 from Feed import Feed |
5 from FeedUpdater import updateAllFeeds | |
5 import Mapping | 6 import Mapping |
6 import socket | 7 import socket |
7 from sqlalchemy import create_engine | 8 from sqlalchemy import create_engine |
8 from sqlalchemy.orm import sessionmaker | 9 from sqlalchemy.orm import sessionmaker |
9 | 10 |
18 def createFeed(session): | 19 def createFeed(session): |
19 newFeed = Feed("Joel on Software", "http://www.joelonsoftware.com/rss.xml") | 20 newFeed = Feed("Joel on Software", "http://www.joelonsoftware.com/rss.xml") |
20 session.add(newFeed) | 21 session.add(newFeed) |
21 session.commit() | 22 session.commit() |
22 | 23 |
24 def listFeeds(session): | |
25 allFeeds = session.query(Feed) | |
26 for feed in allFeeds: | |
27 print "\n\nfeed: " + feed.name | |
28 for entry in feed.entries: | |
29 print entry.title | |
30 | |
23 if __name__ == "__main__": | 31 if __name__ == "__main__": |
24 databaseUrl = loadDatabaseProperties() | 32 databaseUrl = loadDatabaseProperties() |
25 engine = create_engine(databaseUrl,echo=True) | 33 engine = create_engine(databaseUrl,echo=True) |
26 Mapping.createMapping(engine) | 34 Mapping.createMapping(engine) |
27 SessionMaker = sessionmaker(bind = engine) | 35 SessionMaker = sessionmaker(bind = engine) |
28 session = SessionMaker() | 36 session = SessionMaker() |
29 | 37 |
30 createFeed(session) | 38 #createFeed(session) |
39 updateAllFeeds(session) | |
40 #listFeeds(session) |