]> asedeno.scripts.mit.edu Git - bluechips.git/commitdiff
Don't import meta.Session directly; import meta instead
authorEvan Broder <broder@mit.edu>
Fri, 18 Jul 2008 04:03:52 +0000 (04:03 +0000)
committerEvan Broder <broder@mit.edu>
Fri, 18 Jul 2008 04:03:52 +0000 (04:03 +0000)
bluechips/lib/totals.py

index 3cdbf45efbdec674d8bfc14df8fc17b85396c181..3f18a32d115d46ddee1fce3017412074a6a5a6d5 100644 (file)
@@ -3,7 +3,7 @@ Calculate the total state of the books
 """
 
 from bluechips import model
 """
 
 from bluechips import model
-from bluechips.model.meta import Session
+from bluechips.model import meta
 
 import sqlalchemy
 
 
 import sqlalchemy
 
@@ -19,7 +19,7 @@ def debts():
     # In this scheme, negative numbers represent money the house owes
     # the user, and positive numbers represent money the user owes the
     # house
     # In this scheme, negative numbers represent money the house owes
     # the user, and positive numbers represent money the user owes the
     # house
-    users = Session.query(model.User)
+    users = meta.Session.query(model.User)
     
     debts = {}
     
     
     debts = {}
     
@@ -30,7 +30,7 @@ def debts():
     # Next, debit everyone for expenditures that they have an
     # investment in (i.e. splits)
     
     # Next, debit everyone for expenditures that they have an
     # investment in (i.e. splits)
     
-    total_splits = Session.query(model.Split).\
+    total_splits = meta.Session.query(model.Split).\
         add_column(sqlalchemy.func.sum(model.Split.share).label('total_split')).\
         group_by(model.Split.user_id)
     
         add_column(sqlalchemy.func.sum(model.Split.share).label('total_split')).\
         group_by(model.Split.user_id)
     
@@ -42,7 +42,7 @@ def debts():
     # To keep this from getting to be expensive, have SQL sum up
     # transfers for us
     
     # To keep this from getting to be expensive, have SQL sum up
     # transfers for us
     
-    transfer_q = Session.query(model.Transfer).\
+    transfer_q = meta.Session.query(model.Transfer).\
         add_column(sqlalchemy.func.sum(model.Transfer.amount).label('total_amount'))
     total_debits = transfer_q.group_by(model.Transfer.debtor_id)
     total_credits = transfer_q.group_by(model.Transfer.creditor_id)
         add_column(sqlalchemy.func.sum(model.Transfer.amount).label('total_amount'))
     total_debits = transfer_q.group_by(model.Transfer.debtor_id)
     total_credits = transfer_q.group_by(model.Transfer.creditor_id)