diff --git a/setup.py b/setup.py index f88ed51..8457b23 100644 --- a/setup.py +++ b/setup.py @@ -36,7 +36,6 @@ "tw2.core>=2.0b2", "tw2.jquery", "tw2.jqplugins.ui>=2.0b7", - "tw2.sqla", "six", ], extras_require = { diff --git a/tw2/jqplugins/jqgrid/samples/model.py b/tw2/jqplugins/jqgrid/samples/model.py index 6d14430..d4277af 100644 --- a/tw2/jqplugins/jqgrid/samples/model.py +++ b/tw2/jqplugins/jqgrid/samples/model.py @@ -86,7 +86,7 @@ def __unicode__(self): def populateDB(sess): if Person.query.count() > 0: - print "Not populating DB. Already stuff in there." + print("Not populating DB. Already stuff in there.") return firsts = ["Sally", "Suzie", "Sandy", @@ -126,7 +126,7 @@ def populateDB(sess): benalis = Person.query.filter_by(last_name='Ben Ali').all() dictators = qaddafis + mubaraks + benalis - print "populating dictators friends" + print("populating dictators friends") for p1 in dictators: for p2 in dictators: if p1 == p2 or p1 in p2.friends: @@ -135,7 +135,7 @@ def populateDB(sess): p1.friends.append(p2) p2.friends.append(p1) - print "populating everyone else's friends" + print("populating everyone else's friends") for p1 in Person.query.all(): for p2 in Person.query.all(): if p1 == p2 or p1 in p2.friends: @@ -144,7 +144,7 @@ def populateDB(sess): p1.friends.append(p2) p2.friends.append(p1) - print "done populating DB" + print("done populating DB") populateDB(session) transaction.commit() diff --git a/tw2/jqplugins/jqgrid/widgets/core.py b/tw2/jqplugins/jqgrid/widgets/core.py index c88e084..28a6787 100644 --- a/tw2/jqplugins/jqgrid/widgets/core.py +++ b/tw2/jqplugins/jqgrid/widgets/core.py @@ -6,6 +6,7 @@ import tw2.jqplugins.ui.base as tw2_jq_ui from tw2.jqplugins.jqgrid import base +from six.moves import map _pager_defaults = { 'enableSearch': True, @@ -58,5 +59,5 @@ def prepare(self): self._prmDel = encoder.encode(self.prmDel) self._prmSearch = encoder.encode(self.prmSearch) self._prmView = encoder.encode(self.prmView) - self._custom_pager_buttons = map(encoder.encode, - self.custom_pager_buttons) + self._custom_pager_buttons = list(map(encoder.encode, + self.custom_pager_buttons)) diff --git a/tw2/jqplugins/jqgrid/widgets/sqla.py b/tw2/jqplugins/jqgrid/widgets/sqla.py index 7acc384..9837507 100644 --- a/tw2/jqplugins/jqgrid/widgets/sqla.py +++ b/tw2/jqplugins/jqgrid/widgets/sqla.py @@ -1,5 +1,3 @@ -from __future__ import print_function - import tw2.core import tw2.core.util from tw2.core.resources import encoder @@ -18,6 +16,12 @@ import math import transaction +from past.builtins import cmp +from six import text_type +from six.moves import filter +from six.moves import map +from functools import reduce + COUNT_PREFIX = '__count_' @@ -145,9 +149,9 @@ def massage(entry, prop): if prop.uselist: data = len(data) else: - data = unicode(data) + data = text_type(data) elif is_relation(prop) and not prop.uselist: - data = unicode(data) + data = text_type(data) if isinstance(data, (datetime.datetime, datetime.date)): data = data.strftime(cls.datetime_format) @@ -244,7 +248,7 @@ def _build_sorted_query(cls, kw): subquery_lookup = cls._get_subquery_lookup() query_args, subqueries = {}, {} - for attribute, l in subquery_lookup.iteritems(): + for attribute, l in subquery_lookup.items(): subquery = session.query( dotted_getattr(l['cls'], l['local']), sqlalchemy.sql.func.count('*').label(attribute) @@ -259,9 +263,9 @@ def _build_sorted_query(cls, kw): query_args[attribute] = getattr(subquery.c, attribute) subqueries[attribute] = subquery - query = session.query(cls.entity, *query_args.values()) + query = session.query(cls.entity, *list(query_args.values())) - for attribute, l in subquery_lookup.iteritems(): + for attribute, l in subquery_lookup.items(): query = query.outerjoin(( subqueries[attribute], getattr(cls.entity, l['remote']) == @@ -408,7 +412,7 @@ def _request_query(cls, req): kw.update(req.params) # Cast things to integers - kw['page'], kw['rows'] = map(int, [kw['page'], kw['rows']]) + kw['page'], kw['rows'] = list(map(int, [kw['page'], kw['rows']])) base = cls._build_sorted_query(kw)