Remove custom GMQuery class

We provided a custom GMQuery class that offered a .sort() method for
compatibility with the Mongo syntax. Now that we have settled for sqlalchemy
which uses the order_by() method, we can safely remove this custom class
and move a little closer to "pure" and native sqlalchemy usage.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
This commit is contained in:
Sebastian Spaeth 2013-01-07 13:52:14 +01:00
parent 39dc3bf8db
commit 20be9bb77d
2 changed files with 2 additions and 15 deletions

View File

@ -17,21 +17,8 @@
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import scoped_session, sessionmaker, object_session
from sqlalchemy.orm.query import Query
def _get_query_model(query):
cols = query.column_descriptions
assert len(cols) == 1, "These functions work only on simple queries"
return cols[0]["type"]
class GMGQuery(Query):
def sort(self, key):
key_col = getattr(_get_query_model(self), key)
return self.order_by(key_col)
Session = scoped_session(sessionmaker(query_cls=GMGQuery))
Session = scoped_session(sessionmaker())
class GMGTableBase(object):

View File

@ -514,7 +514,7 @@ def collection_atom_feed(request):
cursor = CollectionItem.query.filter_by(
collection=collection.id) \
.sort(CollectionItem.added.desc()) \
.order_by(CollectionItem.added.desc()) \
.limit(ATOM_DEFAULT_NR_OF_UPDATED_ITEMS)
"""