[tor-commits] [pytorctl/master] backward compatibility with SQLAlchemy 0.5.x

mikeperry at torproject.org mikeperry at torproject.org
Fri Jun 24 19:30:02 UTC 2011


commit c8fee8b7b5ea6c584bb5a75647ee44737e60b66d
Author: aagbsn <aagbsn at extc.org>
Date:   Sun Apr 10 23:59:09 2011 -0700

    backward compatibility with SQLAlchemy 0.5.x
---
 SQLSupport.py |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/SQLSupport.py b/SQLSupport.py
index 2bd0a8f..9e1a4cb 100644
--- a/SQLSupport.py
+++ b/SQLSupport.py
@@ -63,6 +63,10 @@ def setup_db(db_uri, echo=False, drop=False):
     # wouldn't kill you, you know.
     tc_session.add = tc_session.save_or_update
 
+  if sqlalchemy.__version__ < "0.6.0":
+    # clear() replaced with expunge_all
+    tc_session.clear = tc_session.expunge_all
+
 class Router(Entity):
   using_options(shortnames=True, order_by='-published', session=tc_session, metadata=tc_metadata)
   using_mapper_options(save_on_init=False)
@@ -374,7 +378,7 @@ class RouterStats(Entity):
   _compute_stats = Callable(_compute_stats)
 
   def _compute_ranks():
-    tc_session.clear()
+    tc_session.expunge_all()
     min_r = select([func.min(BwHistory.rank)],
         BwHistory.table.c.router_idhex
             == RouterStats.table.c.router_idhex).as_scalar()





More information about the tor-commits mailing list