TG-2.2 Error when browsing tables on admin interface when using PostgreSQL

60 views
Skip to first unread message

Erni Wogernom

unread,
Nov 2, 2012, 12:15:41 PM11/2/12
to turbo...@googlegroups.com
Hi there,

After upgrading to TG-2.2 I noticed the following error (see below) when browsing pages in admin/ controller like: admin/groups/. The error paper only when I am using real-db (PostgreSQL) and does not appear when I am using sqlite.

Any idea how to fix this?

Thanks,

Erni.


Error - <type 'exceptions.TypeError'>: __len__() should return an int
File '/home/erni/prefix/TurboGears-2.2/lib/python2.7/site-packages/WebError-0.10.3-py2.7.egg/weberror/errormiddleware.py', line 162 in __call__
  app_iter = self.application(environ, sr_checker)
File '/home/erni/prefix/TurboGears-2.2/lib/python2.7/site-packages/TurboGears2-2.2.0-py2.7.egg/tg/configuration/app_config.py', line 894 in remover
  return app(environ, start_response)
File '/home/erni/prefix/TurboGears-2.2/lib/python2.7/site-packages/repoze.tm2-1.0-py2.7.egg/repoze/tm/__init__.py', line 24 in __call__
  result = self.application(environ, save_status_and_headers)
File '/home/erni/prefix/TurboGears-2.2/lib/python2.7/site-packages/repoze.who-2.0-py2.7.egg/repoze/who/middleware.py', line 87 in __call__
  app_iter = app(environ, wrapper.wrap_start_response)
File '/home/erni/prefix/TurboGears-2.2/lib/python2.7/site-packages/tw2.core-2.1.2-py2.7.egg/tw2/core/middleware.py', line 195 in __call__
  resp = req.get_response(self.app, catch_exc_info=True)
File 'build/bdist.linux-x86_64/egg/webob/request.py', line 1082 in get_response
File 'build/bdist.linux-x86_64/egg/webob/request.py', line 1055 in call_application
File '/home/erni/prefix/TurboGears-2.2/lib/python2.7/site-packages/Beaker-1.6.3-py2.7.egg/beaker/middleware.py', line 73 in __call__
  return self.app(environ, start_response)
File '/home/erni/prefix/TurboGears-2.2/lib/python2.7/site-packages/Beaker-1.6.3-py2.7.egg/beaker/middleware.py', line 155 in __call__
  return self.wrap_app(environ, session_start_response)
File '/home/erni/prefix/TurboGears-2.2/lib/python2.7/site-packages/Routes-1.13-py2.7.egg/routes/middleware.py', line 131 in __call__
  response = self.app(environ, start_response)
File '/home/erni/prefix/TurboGears-2.2/lib/python2.7/site-packages/Pylons-1.0-py2.7.egg/pylons/wsgiapp.py', line 107 in __call__
  response = self.dispatch(controller, environ, start_response)
File '/home/erni/prefix/TurboGears-2.2/lib/python2.7/site-packages/Pylons-1.0-py2.7.egg/pylons/wsgiapp.py', line 312 in dispatch
  return controller(environ, start_response)
File '/home/erni/my_example/my_example.front/my_example/lib/base.py', line 31 in __call__
  return TGController.__call__(self, environ, start_response)
File '/home/erni/prefix/TurboGears-2.2/lib/python2.7/site-packages/Pylons-1.0-py2.7.egg/pylons/controllers/core.py', line 211 in __call__
  response = self._dispatch_call()
File '/home/erni/prefix/TurboGears-2.2/lib/python2.7/site-packages/Pylons-1.0-py2.7.egg/pylons/controllers/core.py', line 162 in _dispatch_call
  response = self._inspect_call(func)
File '/home/erni/prefix/TurboGears-2.2/lib/python2.7/site-packages/Pylons-1.0-py2.7.egg/pylons/controllers/core.py', line 105 in _inspect_call
  result = self._perform_call(func, args)
File '/home/erni/prefix/TurboGears-2.2/lib/python2.7/site-packages/TurboGears2-2.2.0-py2.7.egg/tg/controllers/dispatcher.py', line 127 in _perform_call
  r = self._call(func, params, remainder=remainder)
File '/home/erni/prefix/TurboGears-2.2/lib/python2.7/site-packages/TurboGears2-2.2.0-py2.7.egg/tg/controllers/decoratedcontroller.py', line 143 in _call
  tg_decoration.run_hooks('before_render', remainder, params, output)
File '/home/erni/prefix/TurboGears-2.2/lib/python2.7/site-packages/TurboGears2-2.2.0-py2.7.egg/tg/decorators.py', line 75 in run_hooks
  func(*l, **kw)
File '/home/erni/prefix/TurboGears-2.2/lib/python2.7/site-packages/TurboGears2-2.2.0-py2.7.egg/tg/decorators.py', line 582 in before_render
  paginator.paginate_items_per_page, controller='/')
File '/home/erni/prefix/TurboGears-2.2/lib/python2.7/site-packages/WebHelpers-1.3-py2.7.egg/webhelpers/paginate.py', line 413 in __init__
  self.item_count = len(self.collection)
TypeError: __len__() should return an int
  

Carlos Daniel Ruvalcaba Valenzuela

unread,
Nov 5, 2012, 1:48:00 PM11/5/12
to turbo...@googlegroups.com
Perhaps you can share your shema/models?, I have a related problem
that is triggered by a specific model, not sure what it is, seems like
datetime fields, but I will try to go deep into this afternoon and
would be helpful to check your problems at once (as they seem
related).

Regards,
Carlos Daniel Ruvalcaba Valenzuela

On Mon, Nov 5, 2012 at 9:09 AM, Fernando González
<fernando....@gmail.com> wrote:
>> Hi, same problem here.
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "TurboGears" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/turbogears/-/nQumyCfd7r4J.
>
> To post to this group, send email to turbo...@googlegroups.com.
> To unsubscribe from this group, send email to
> turbogears+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/turbogears?hl=en.

Carlos Daniel Ruvalcaba Valenzuela

unread,
Nov 5, 2012, 4:34:54 PM11/5/12
to turbo...@googlegroups.com
This seems to be a problem going back to tgext.crud, seems like the
special paginator that tgext.crud uses does not follow the __len__
protocol strictly and python raises this error.

Normally the length of the list or collection is given as an int, but
I imagine psycopg2 returns a long somewhere and the class
SmartPaginationCollection does not check this and just uses it as is.

I will fill a bug later on github, I already have a working patch but
perhaps this needs some fixing deeper on.

Regards,
Carlos Daniel Ruvalcaba Valenzuela

Erni Wogernom

unread,
Nov 5, 2012, 5:30:23 PM11/5/12
to turbo...@googlegroups.com
  Great, thank you for looking this up Carlos! 

  So how can I fix this on my side? Would I be able to do something like:

$ easy_install -U -i http://www.turbogears.org/2.2/downloads/current/index tg.devtools

  or I will need to get SVN version?

  Thanks again!

Erni.

Carlos Daniel Ruvalcaba Valenzuela

unread,
Nov 5, 2012, 6:01:56 PM11/5/12
to turbo...@googlegroups.com

I submitted a pull request to the tag github report, you can in the mean time pull/download from my fork:

https://github.com/clsdaniel/tgext.crud

And install manually.

python setup.pay install

Regards,
Carlos Daniel Ruvalcaba Valenzuela

Erni Wogernom

unread,
Nov 9, 2012, 12:51:49 PM11/9/12
to turbo...@googlegroups.com
Great, thank you Carlos!
Reply all
Reply to author
Forward
0 new messages