comparison Mapping.py @ 68:525a52169f60

Make FeedEntry table object available in Mapping to use it to expire old, read feed entries.
author Dirk Olmes <dirk@xanthippe.ping.de>
date Tue, 10 Aug 2010 03:32:29 +0200
parents b535bce50626
children f909550683b0
comparison
equal deleted inserted replaced
67:c3f2b11e7420 68:525a52169f60
13 from sqlalchemy import Text 13 from sqlalchemy import Text
14 from sqlalchemy.orm import mapper 14 from sqlalchemy.orm import mapper
15 from sqlalchemy.orm import relation 15 from sqlalchemy.orm import relation
16 16
17 mappingDefined = False 17 mappingDefined = False
18 feedEntryTable = None
18 19
19 def createMapping(engine): 20 def createMapping(engine):
20 """ Make sure the mapping is defined only once. This is not really needed for the feed updater 21 """ Make sure the mapping is defined only once. This is not really needed for the feed updater
21 or the GUI app but comes in handy when working interactively with the system. """ 22 or the GUI app but comes in handy when working interactively with the system. """
22 global mappingDefined 23 global mappingDefined
24 _createMapping(engine) 25 _createMapping(engine)
25 mappingDefined = True 26 mappingDefined = True
26 27
27 def _createMapping(engine): 28 def _createMapping(engine):
28 metadata = MetaData(engine) 29 metadata = MetaData(engine)
30 metadata.bind = engine
29 31
30 feedTable = Table("feed", metadata, 32 feedTable = Table("feed", metadata,
31 Column("pk", Integer, primary_key=True), 33 Column("pk", Integer, primary_key=True),
32 Column("title", String(255), nullable=False), 34 Column("title", String(255), nullable=False),
33 Column("rss_url", String(255), nullable=False), 35 Column("rss_url", String(255), nullable=False),
36 # when displaying an entry of this feed, do not display the summary but rather load 38 # when displaying an entry of this feed, do not display the summary but rather load
37 # the link directly 39 # the link directly
38 Column("auto_load_entry_link", Boolean, nullable=False) 40 Column("auto_load_entry_link", Boolean, nullable=False)
39 ) 41 )
40 42
43 global feedEntryTable
41 feedEntryTable = Table("feed_entry", metadata, 44 feedEntryTable = Table("feed_entry", metadata,
42 Column("pk", Integer, primary_key=True), 45 Column("pk", Integer, primary_key=True),
43 Column("create_timestamp", DateTime, nullable=False), 46 Column("create_timestamp", DateTime, nullable=False),
44 Column("read", Integer, nullable=False), 47 Column("read", Integer, nullable=False),
45 48