you can't call count() when you've used from_statement, that should be raising an error. the bug is that no error is being raised.
Hollister wrote: > > Here you go: > > URL: http://dev:5000/hits/referrers > File '/home/aw/venv/dev/lib/python2.6/site-packages/WebError-0.10.1- > py2.6.egg/weberror/evalexception.py', line 431 in respond > app_iter = self.application(environ, detect_start_response) > File '/home/aw/venv/dev/lib/python2.6/site-packages/Beaker-1.3- > py2.6.egg/beaker/middleware.py', line 81 in __call__ > return self.app(environ, start_response) > File '/home/aw/venv/dev/lib/python2.6/site-packages/Beaker-1.3- > py2.6.egg/beaker/middleware.py', line 160 in __call__ > return self.wrap_app(environ, session_start_response) > File '/home/aw/venv/dev/lib/python2.6/site-packages/Routes-1.10.3- > py2.6.egg/routes/middleware.py', line 130 in __call__ > response = self.app(environ, start_response) > File '/home/aw/venv/dev/lib/python2.6/site-packages/Pylons-0.9.7- > py2.6.egg/pylons/wsgiapp.py', line 125 in __call__ > response = self.dispatch(controller, environ, start_response) > File '/home/aw/venv/dev/lib/python2.6/site-packages/Pylons-0.9.7- > py2.6.egg/pylons/wsgiapp.py', line 324 in dispatch > return controller(environ, start_response) > File '/home/aw/projects/resonate/corp/corp/lib/base.py', line 18 in > __call__ > return WSGIController.__call__(self, environ, start_response) > File '/home/aw/venv/dev/lib/python2.6/site-packages/Pylons-0.9.7- > py2.6.egg/pylons/controllers/core.py', line 221 in __call__ > response = self._dispatch_call() > File '/home/aw/venv/dev/lib/python2.6/site-packages/Pylons-0.9.7- > py2.6.egg/pylons/controllers/core.py', line 172 in _dispatch_call > response = self._inspect_call(func) > File '/home/aw/venv/dev/lib/python2.6/site-packages/Pylons-0.9.7- > py2.6.egg/pylons/controllers/core.py', line 107 in _inspect_call > result = self._perform_call(func, args) > File '/home/aw/venv/dev/lib/python2.6/site-packages/Pylons-0.9.7- > py2.6.egg/pylons/controllers/core.py', line 60 in _perform_call > return func(**args) > File '/home/aw/projects/resonate/corp/corp/controllers/hits.py', line > 67 in referrers > items_per_page = 50, > File '/home/aw/venv/dev/lib/python2.6/site-packages/WebHelpers-0.6.4- > py2.6.egg/webhelpers/paginate.py', line 333 in __init__ > self.item_count = len(self.collection) > File '/home/aw/venv/dev/lib/python2.6/site-packages/WebHelpers-0.6.4- > py2.6.egg/webhelpers/paginate.py', line 204 in __len__ > return self.obj.count() > File '/home/aw/venv/dev/lib/python2.6/site-packages/SQLAlchemy-0.5.2- > py2.6.egg/sqlalchemy/orm/query.py', line 1465 in count > should_nest = should_nest[0] > File '/home/aw/venv/dev/lib/python2.6/site-packages/SQLAlchemy-0.5.2- > py2.6.egg/sqlalchemy/orm/query.py', line 1472 in _col_aggregate > entity.setup_context(self, context) > File '/home/aw/venv/dev/lib/python2.6/site-packages/SQLAlchemy-0.5.2- > py2.6.egg/sqlalchemy/orm/query.py', line 1956 in setup_context > if context.order_by is False and self.mapper.order_by: > AttributeError: 'QueryContext' object has no attribute 'order_by' > > On Jun 19, 12:35 pm, "Michael Bayer" <mike...@zzzcomputing.com> wrote: >> Hollister wrote: >> >> >> When I run this, I get: >> >> >> Module sqlalchemy.orm.query:1956 in setup_context >> >> << context.froms.append(self.selectable) >> >> if context.order_by is False and self.mapper.order_by: >> >> context.order_by = self.mapper.order_by>> if >> >> context.order_by is False and self.mapper.order_by: >> >> I need a full stack trace on this since once from_statement() is called, >> setup_context() should never be called. >> >> >> >> >> AttributeError: 'QueryContext' object has no attribute 'order_by' >> >> >> This evidently has nothing to do with the query's order_by clause >> >> since I get the same error if I remove it. If I execute the query and >> >> pass the results to paginate: >> >> >> results = query.all() >> >> >> c.paginator = paginate.Page( >> >> results, >> >> page = int(request.params.get('page', 1)), >> >> items_per_page = 50, >> >> ) >> >> >> I get: >> >> >> AttributeError: 'Hit' object has no attribute 'count' >> >> >> Which I guess makes sense, since I don't have that defined in my >> >> class. >> >> >> What am I doing wrong? >> >> > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---