hooks/__init__.py
changeset 7648 5d5d98930247
parent 7456 c54038622fc9
child 7708 45be3a9debe6
--- a/hooks/__init__.py	Mon Jul 11 15:05:19 2011 +0200
+++ b/hooks/__init__.py	Mon Jul 11 19:48:37 2011 +0200
@@ -46,26 +46,26 @@
                 session.commit()
             finally:
                 session.close()
-        self.repo.looping_task(60*60*24, cleanup_old_transactions, self.repo)
+        if self.repo.config['undo-support']:
+            self.repo.looping_task(60*60*24, cleanup_old_transactions,
+                                   self.repo)
         def update_feeds(repo):
-            session = repo.internal_session()
-            try:
-                # don't iter on repo.sources which doesn't include copy based
-                # sources (the one we're looking for)
-                for source in repo.sources_by_eid.itervalues():
-                    if (not source.copy_based_source
-                        or not repo.config.source_enabled(source)
-                        or not source.config['synchronize']):
-                        continue
-                    try:
-                        stats = source.pull_data(session)
-                        if stats.get('created'):
-                            source.info('added %s entities', len(stats['created']))
-                        if stats.get('updated'):
-                            source.info('updated %s entities', len(stats['updated']))
-                    except Exception, exc:
-                        session.exception('while trying to update feed %s', source)
-                    session.set_cnxset()
-            finally:
-                session.close()
+            # don't iter on repo.sources which doesn't include copy based
+            # sources (the one we're looking for)
+            for source in repo.sources_by_eid.itervalues():
+                if (not source.copy_based_source
+                    or not repo.config.source_enabled(source)
+                    or not source.config['synchronize']):
+                    continue
+                session = repo.internal_session()
+                try:
+                    stats = source.pull_data(session)
+                    if stats.get('created'):
+                        source.info('added %s entities', len(stats['created']))
+                    if stats.get('updated'):
+                        source.info('updated %s entities', len(stats['updated']))
+                except Exception, exc:
+                    session.exception('while trying to update feed %s', source)
+                finally:
+                    session.close()
         self.repo.looping_task(60, update_feeds, self.repo)