Mercurial > hg > Feedworm
diff Mapping.py @ 34:5813e3c10f14
move the database logic out into its own module. Make everything reload safe so that multiple sessions can be created from interactive sessions
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Wed, 05 May 2010 02:14:05 +0200 |
parents | ee1432a91141 |
children | aaec263f07ca |
line wrap: on
line diff
--- a/Mapping.py Fri Apr 30 06:22:33 2010 +0200 +++ b/Mapping.py Wed May 05 02:14:05 2010 +0200 @@ -12,7 +12,17 @@ from sqlalchemy.orm import mapper from sqlalchemy.orm import relation +mappingDefined = False + def createMapping(engine): + """ Make sure the mapping is defined only once. This is not really needed for the feed updater + or the GUI app but comes in handy when working interactively with the system. """ + global mappingDefined + if not mappingDefined: + _createMapping(engine) + mappingDefined = True + +def _createMapping(engine): metadata = MetaData(engine) feedTable = Table("feed", metadata,