--- a/iro/model/schema.py Sat Jan 28 04:03:46 2012 +0100
+++ b/iro/model/schema.py Sat Jan 28 12:24:40 2012 +0100
@@ -5,7 +5,9 @@
#relationship
from sqlalchemy import ForeignKey
-from sqlalchemy.orm import relationship, backref
+from sqlalchemy.orm import relationship, backref, object_session
+
+from sqlalchemy import and_
Base = declarative_base()
@@ -74,5 +76,11 @@
def __repr__(self):
return "<User('%s','%s')>"%(self.name,self.apikey)
-
-
+
+ def routes(self, typ, isDefault = None):
+ filters=[User.name == self.name,
+ Offer.typ == typ,
+ ]
+ if isDefault is not None:
+ filters.append(Userright.isDefault==isDefault)
+ return object_session(self).query(Userright.offer_name).join(Offer,User).filter(and_(*filters))