Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #771 (closed defect: fixed)

Opened 13 years ago

Last modified 12 years ago

[PATCH][TEST] Unable to create TG_User via Catwalk

Reported by: plewis Owned by: anonymous
Priority: highest Milestone: 0.9a5
Component: Identity Version: 0.9a4
Severity: blocker Keywords:
Cc:

Description

Trying to add a new user via Catwalk results in the following exception:

TypeError: TG_User() did not get expected keyword argument user_name

What is happening is that the filter for Identity is stripping out the 'user_name' and 'password' fields. Normally, this would be desired, as you probably don't want these fields being passed on to your controller once identity has done its authentication. But in this case, the controller really needs the user name and password so that it can set up the user.

This error will also cause problems on any setup type forms (where you are trying to set up a new user) that contain the inputs 'user_name' and 'password'.

A thread that goes into a bit of discussion about the error:  http://groups.google.com/group/turbogears/browse_frm/thread/938dc5aad28581c7

Attachments

test-771.zip Download (29.1 KB) - added by godoy 13 years ago.
This is a test application.
identity_parameters_test.patch Download (1.0 KB) - added by plewis 13 years ago.
Sorry, Jorge, you are right, there was a bug in the test case. It should be fixed.
identity_login.patch Download (8.2 KB) - added by plewis 13 years ago.
Unified test and patch

Change History

comment:1 Changed 13 years ago by plewis

  • Summary changed from Unable to create TG_User via Catwalk to [TEST] Unable to create TG_User via Catwalk

comment:2 Changed 13 years ago by godoy

This can be confirmed with a new application and then trying to create a user with CatWalk after enabling Identity and Visit.

The Traceback is:

Traceback (most recent call last):
  File "/usr/lib/python2.4/site-packages/CherryPy-2.2.0-py2.4.egg/cherrypy/_cphttptools.py", line 106, in _run
    self.main()
  File "/usr/lib/python2.4/site-packages/CherryPy-2.2.0-py2.4.egg/cherrypy/_cphttptools.py", line 255, in main
    body = page_handler(*virtual_path, **self.params)
  File "<string>", line 3, in add
  File "/home/godoy/desenvolvimento/python/TurboGears/trunk/turbogears/controllers.py", line 206, in expose
    output = database.run_with_transaction(expose._expose,func, accept, allow_json, allow_json_from_config,*args, **kw)
  File "/home/godoy/desenvolvimento/python/TurboGears/trunk/turbogears/database.py", line 216, in run_with_transaction
    retval = func(*args, **kw)
  File "<string>", line 5, in _expose
  File "/home/godoy/desenvolvimento/python/TurboGears/trunk/turbogears/controllers.py", line 227, in <lambda>
    expose._expose.when(rule)(lambda _func, accept, allow_json, allow_json_from_config,*args,**kw: _execute_func(
  File "/home/godoy/desenvolvimento/python/TurboGears/trunk/turbogears/controllers.py", line 248, in _execute_func
    output = errorhandling.try_call(func, *args, **kw)
  File "/home/godoy/desenvolvimento/python/TurboGears/trunk/turbogears/errorhandling.py", line 71, in try_call
    return func(self, *args, **kw)
  File "/home/godoy/desenvolvimento/python/TurboGears/trunk/turbogears/toolbox/catwalk/__init__.py", line 786, in add
    new_object = obj(**params)
  File "/home/godoy/desenvolvimento/python/TurboGears/trunk/thirdparty/sqlobject/sqlobject/declarative.py", line 92, in _wrapper
    return_value = fn(self, *args, **kwargs)
  File "/home/godoy/desenvolvimento/python/TurboGears/trunk/thirdparty/sqlobject/sqlobject/main.py", line 1197, in __init__
    self._create(id, **kw)
  File "/home/godoy/desenvolvimento/python/TurboGears/trunk/thirdparty/sqlobject/sqlobject/inheritance/__init__.py", line 218, in _create
    super(InheritableSQLObject, self)._create(id, **kw)
  File "/home/godoy/desenvolvimento/python/TurboGears/trunk/thirdparty/sqlobject/sqlobject/main.py", line 1216, in _create
    raise TypeError, "%s() did not get expected keyword argument %s" % (self.__class__.__name__, column.name)
TypeError: TG_User() did not get expected keyword argument user_name

I'll test the provided patch...

comment:3 Changed 13 years ago by godoy

I haven't applied and used this patch, but isn't there a bug in it? You call the url as "username" when the expected is "user_name".

I remember that sometime it was decided to remove these from exposed methods to avoid some kind of leaking, but I don't remember when.

The funny thing is that a while ago I tested the Wiki process for creating new accounts and it worked, so it was later than when the change was made. At least for CatWalk we need this to work because that's the documented way to add "the first" user to a system.

Changed 13 years ago by godoy

This is a test application.

comment:4 Changed 13 years ago by godoy

  • Priority changed from normal to highest
  • Severity changed from normal to blocker

comment:5 Changed 13 years ago by kevin

  • Milestone changed from 0.9 to 0.9a5

FYI, at the end of the thread Alberto comments that get_object_trail doesn't cache. If you look in turbogears.startup, we actually monkeypatch get_object_trail so that it *does* cache. This is pretty important, so I'm moving this to a5.

Changed 13 years ago by plewis

Sorry, Jorge, you are right, there was a bug in the test case. It should be fixed.

comment:6 Changed 13 years ago by plewis

  • Summary changed from [TEST] Unable to create TG_User via Catwalk to [PATCH][TEST] Unable to create TG_User via Catwalk

Ok, as I described in the google groups discussion, Catwalk presented a unique problem, as the add() method took a variable parameter list, and so there was no way to tell if the user_name and password parameters should be passed on. So, we now explicitly identify the login form as such and only strip out parameters when processing the login form. Instead of using a hidden form variable, I am looking for the "login" submit button. This name is specified in the config file, so it should offer a fair degree of flexibility.

Note the backwards incompatibility stated in the changelog.

comment:7 Changed 13 years ago by plewis

the identity_login.patch file has both the patch and the test.

Changed 13 years ago by plewis

Unified test and patch

comment:8 Changed 13 years ago by kevin

  • Status changed from new to closed
  • Resolution set to fixed

committed in [1276]

Note: See TracTickets for help on using tickets.