0.9a5 identity (traceback included)

0 views
Skip to first unread message

Rune Hansen

unread,
May 3, 2006, 4:41:16 PM5/3/06
to turbo...@googlegroups.com
Hi, 
I've created a project with 09a5 using identity. Everything is at default values.
I've made sure that identity works with these default values.

Now, I'm trying to follow the "advice" in model.py:

class User(SQLObject):
    """
    Reasonably basic User definition. ___Probably_would_want_additional_attributes___.
    """
.
.
So I've added:
locale = EnumCol(enumValues=['no','en','se','dk']) 
to class User, because it seems like a reasonable thing to do.

I dropped the "default" database and ran tg-admin create sql with my modified model.py to create the tables.
(yes, I'm stating the obvious but rather than spend time and bandwidth answering "yes"  to the inevitable questions..... :) )

Finally, after using catwalk to set up a user/group, I get this exception when accessing my app:

Page handler: <bound method Root.login of <scanmineadmin.controllers.root.Root object at 0xb7790a6c>>
Traceback (most recent call last):
  File "/home/webdeveloper/lib/python2.4/site-packages/CherryPy-2.2.1-py2.4.egg/cherrypy/_cphttptools.py", line 105, in _run
    self.main()
  File "/home/webdeveloper/lib/python2.4/site-packages/CherryPy-2.2.1-py2.4.egg/cherrypy/_cphttptools.py", line 254, in main
    body = page_handler(*virtual_path, **self.params)
  File "<string>", line 3, in login
  File "/home/webdeveloper/lib/python2.4/site-packages/TurboGears-0.9a5-py2.4.egg/turbogears/controllers.py", line 210, in expose
    output = database.run_with_transaction(func._expose,func, accept, allow_json, allow_json_from_config,*args, **kw)
  File "/home/webdeveloper/lib/python2.4/site-packages/TurboGears-0.9a5-py2.4.egg/turbogears/database.py", line 216, in run_with_transaction
    retval = func(*args, **kw)
  File "<string>", line 5, in _expose
  File "/home/webdeveloper/lib/python2.4/site-packages/TurboGears-0.9a5-py2.4.egg/turbogears/controllers.py", line 230, in <lambda>
    func._expose.when(rule)(lambda _func, accept, allow_json, allow_json_from_config,*args,**kw: _execute_func(
  File "/home/webdeveloper/lib/python2.4/site-packages/TurboGears-0.9a5-py2.4.egg/turbogears/controllers.py", line 251, in _execute_func
    output = errorhandling.try_call(func, *args, **kw)
  File "/home/webdeveloper/lib/python2.4/site-packages/TurboGears-0.9a5-py2.4.egg/turbogears/errorhandling.py", line 71, in try_call
    return func(self, *args, **kw)
  File "/home/webdeveloper/Sites/scanmineadmin/scanmineadmin/controllers/root.py", line 25, in login
    raise redirect(forward_url)
  File "/home/webdeveloper/lib/python2.4/site-packages/TurboGears-0.9a5-py2.4.egg/turbogears/controllers.py", line 402, in redirect
    raise cherrypy.HTTPRedirect(
  File "/home/webdeveloper/lib/python2.4/site-packages/TurboGears-0.9a5-py2.4.egg/turbogears/controllers.py", line 356, in url
    tgpath = "/".join(list(tgpath))
TypeError: iteration over non-sequence

The traceback does not seem identity related at all. I hope someone can make sense of it :)

regards
/rune


---------------------------------------------------------------------

Behind the firewall, nobody can hear you scream...


Rune Hansen

unread,
May 5, 2006, 3:10:49 AM5/5/06
to turbo...@googlegroups.com
Ok,
As expected the traceback from tg had little to do with the actual error.

What happens is this:

Prerequisite: User, which attempts login, is _not_ member of group "pals"

class MyController(controllers.RootController,identity.SecureResource):
    require = identity.in_group("pals")
Result-> The above traceback.

The (hmmm) "problem" is that when the user has attempted login he/she is may no longer be "Anonymous" and thus
"""        
if not identity.current.anonymous and identity.was_login_attempted():
            raise redirect(forward_url)
"""
becomes True - and a redirect is attempted on a None object.

I would suggest that the line:
"""
if not identity.current.anonymous and identity.was_login_attempted():
"""
is changed to:
"""
if not identity.current.anonymous and identity.was_login_attempted() and not identity.get_identity_errors():
"""
At least until someone that really understands the problem comes along and fixes it ;)

Jorge Godoy

unread,
May 5, 2006, 3:44:53 AM5/5/06
to turbo...@googlegroups.com
Em Sexta 05 Maio 2006 04:10, Rune Hansen escreveu:
>
> I would suggest that the line:
> """
> if not identity.current.anonymous and identity.was_login_attempted():
> """
> is changed to:
> """
> if not identity.current.anonymous and identity.was_login_attempted()
> and not identity.get_identity_errors():
> """
> At least until someone that really understands the problem comes
> along and fixes it ;)

Please, create a ticket for this on Trac.

--
Jorge Godoy <jgo...@gmail.com>

Rune Hansen

unread,
May 5, 2006, 3:57:05 AM5/5/06
to turbo...@googlegroups.com
Ticket #834

Kevin Dangoor

unread,
May 5, 2006, 6:37:07 AM5/5/06
to turbo...@googlegroups.com
On 5/3/06, Rune Hansen <aka.r...@gmail.com> wrote:
> Page handler: <bound method Root.login of
> File
> "/home/webdeveloper/Sites/scanmineadmin/scanmineadmin/controllers/root.py",
> line 25, in login
> raise redirect(forward_url)
> File
> "/home/webdeveloper/lib/python2.4/site-packages/TurboGears-0.9a5-py2.4.egg/turbogears/controllers.py",
> line 402, in redirect
> raise cherrypy.HTTPRedirect(
> File
> "/home/webdeveloper/lib/python2.4/site-packages/TurboGears-0.9a5-py2.4.egg/turbogears/controllers.py",
> line 356, in url
> tgpath = "/".join(list(tgpath))
> TypeError: iteration over non-sequence
>
> The traceback does not seem identity related at all. I hope someone can make
> sense of it :)

It's unclear to me why adding a column would do this, but I'd put a
logging statement in your login method to see what forward_url is. My
guess is that it's None...

Kevin

Kevin Dangoor

unread,
May 5, 2006, 6:38:40 AM5/5/06
to turbo...@googlegroups.com
On 5/5/06, Kevin Dangoor <dan...@gmail.com> wrote:
> It's unclear to me why adding a column would do this, but I'd put a
> logging statement in your login method to see what forward_url is. My
> guess is that it's None...

And, of course, I replied to this after it was already sorted out in
another thread... oh well...

Kevin

Rune Hansen

unread,
May 5, 2006, 6:45:04 AM5/5/06
to turbo...@googlegroups.com
Yes, I ..uhm.. should probably have made it clear that this has nothing to do with extending model.py. I just thought so, at the beginning.
I made a mistake when adding a group, calling it "pal" in stead of "pals". The error occurs when the user it self is authenticated but is not in required group "pals"

In this particular case the traceback should be considered harmful.
Reply all
Reply to author
Forward
0 new messages