comparison backend/sqlalchemy/SqlAlchemyBackend.py @ 173:3bcf39181f6e

pull the calculation of the epxire date up into AbstractBackend
author dirk
date Fri, 09 Sep 2011 17:19:16 +0200
parents f4708d38419c
children 7157bfd3f4d4
comparison
equal deleted inserted replaced
172:214addba1f93 173:3bcf39181f6e
2 from Feed import Feed 2 from Feed import Feed
3 from FeedEntry import FeedEntry 3 from FeedEntry import FeedEntry
4 from FeedUpdater import FeedUpdater 4 from FeedUpdater import FeedUpdater
5 from Preferences import Preferences 5 from Preferences import Preferences
6 from backend.AbstractBackend import AbstractBackend 6 from backend.AbstractBackend import AbstractBackend
7 from datetime import datetime, timedelta
8 from sqlalchemy.orm import joinedload 7 from sqlalchemy.orm import joinedload
9 from sqlalchemy.sql import and_ 8 from sqlalchemy.sql import and_
10 import Database 9 import Database
11 import Mapping 10 import Mapping
12 import logging 11 import logging
117 deleteStatement = feedEntry.delete().where( 116 deleteStatement = feedEntry.delete().where(
118 and_(feedEntry.c.create_timestamp < expireDate, feedEntry.c.read == 1) 117 and_(feedEntry.c.create_timestamp < expireDate, feedEntry.c.read == 1)
119 ) 118 )
120 deleteStatement.execute() 119 deleteStatement.execute()
121 self.session.commit() 120 self.session.commit()
122
123 def _calculateExpireDate(self):
124 now = datetime.now()
125 daysToKeepFeedEntries = self.prefs.daysToKeepFeedEntries()
126 delta = timedelta(days=daysToKeepFeedEntries)
127 return now - delta