Ticket #8936 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

Cannot delete user using AccountModule from web_ui

Reported by: voithos Assigned to: hasienda
Priority: normal Component: AccountManagerPlugin
Severity: normal Keywords: db web_ui
Cc: Trac Release: 0.12

Description

Running trac 0.12.2, with AccountManagerPlugin 0.3dev-r10371. When trying to delete a user (after logging in) using the web_ui interface, it gives the error:

Traceback (most recent call last):
  File "c:\docume~1\voithos\locals~1\temp\easy_install-b06q5m\Trac-0.12.2-py2.6-win32.egg.tmp\trac\web\main.py", line 511, in _dispatch_request
    dispatcher.dispatch(req)
  File "c:\docume~1\voithos\locals~1\temp\easy_install-b06q5m\Trac-0.12.2-py2.6-win32.egg.tmp\trac\web\main.py", line 237, in dispatch
    resp = chosen_handler.process_request(req)
  File "c:\docume~1\voithos\locals~1\temp\easy_install-b06q5m\Trac-0.12.2-py2.6-win32.egg.tmp\trac\prefs\web_ui.py", line 77, in process_request
    template, data = chosen_provider.render_preference_panel(req, panel_id)
  File "build\bdist.win32\egg\acct_mgr\web_ui.py", line 223, in render_preference_panel
    data = {'account': self._do_account(req)}
  File "build\bdist.win32\egg\acct_mgr\web_ui.py", line 290, in _do_account
    data.update(self._do_delete(req))
  File "build\bdist.win32\egg\acct_mgr\web_ui.py", line 363, in _do_delete
    acctmgr.delete_user(user)
NameError: global name 'acctmgr' is not defined

Traced it back to a missing self when calling a function in acctmgr in web_ui.py. From that point on, it no longer gave an error, but it would delete all of the records correctly. When looking at the database, the email record in session_attribute still existed, as did the user's record in session.

Finally managed to fix it by setting the key along with the table name before passing the SQL to cursor.execute().

Attachments

delete_user.diff (1.0 kB) - added by voithos on 06/29/11 23:41:45.
20110630_trac-log_user-delete.txt (2.6 kB) - added by hasienda on 06/30/11 23:38:35.
trac.log snippet from a German localized session trying to delete user test5 via user preferences
20110705_trac_log-user_delete.txt (3.9 kB) - added by voithos on 07/06/11 00:47:23.

Change History

06/29/11 23:41:45 changed by voithos

  • attachment delete_user.diff added.

06/30/11 23:38:35 changed by hasienda

  • attachment 20110630_trac-log_user-delete.txt added.

trac.log snippet from a German localized session trying to delete user test5 via user preferences

(follow-up: ↓ 6 ) 06/30/11 23:43:37 changed by hasienda

  • status changed from new to assigned.

Easy one first: Missing self is confirmed, and is a quick fix indeed, thanks for reporting.

The second is not only totally unrelated, it isn't a valid fix according to my test. What db do you use? My debug log with debug_sql = true reveals, that especially the Trac db table session_attribute is re-populated with details from the current session before finally logging out.

Strange, that I didn't notice that before, but is looks like it isn't that easy to drop a user account from within it's own session. I suspect the same for the session record, but did not check that closely by now. I feel like I did it before, but OTOH I may have never checked the db closely afterwards, as you did. Thanks for the hint as well. but a fix looks not remotely as near here.

06/30/11 23:48:56 changed by hasienda

(In [10372]) AccountManagerPlugin: Correct wrong reference to AcctMgr object, refs #8936.

Thanks to voithos for testing and reporting back.

07/02/11 16:40:50 changed by hasienda

Seems like req.session is the culprit, restoring it's contents to Trac db table session_attribute on logout. I feel like this finding will help resolving #8549 as well.

07/02/11 23:49:53 changed by hasienda

  • summary changed from Cannot delete user using web_ui when running tracd on Windows to Cannot delete user using AccountModule from web_ui.

Seems unrelated to the web server nor the os, so better remove possibly misleading parts of the summary.

07/03/11 00:10:50 changed by hasienda

(In [10375]) AccountManagerPlugin: Really delete user account by AccountModule, refs #8936.

07/06/11 00:47:23 changed by voithos

  • attachment 20110705_trac_log-user_delete.txt added.

(in reply to: ↑ 1 ) 07/06/11 00:55:54 changed by voithos

Replying to hasienda:

The second is not only totally unrelated, it isn't a valid fix according to my test. What db do you use? My debug log with debug_sql = true reveals, that especially the Trac db table session_attribute is re-populated with details from the current session before finally logging out.

I'm just using SQLite. That's funny, my logs don't contain any insert statements at all. Just so you know, I had applied the patch to my local build of AccountManagerPlugin. Granted, I don't really understand why it fixed it on my end, so you might want to go your own route.

07/06/11 01:59:20 changed by hasienda

Seems like your db has only a total of three entries in Trac db table session_attribute for test user 'blah'.

If they don't get changed along the way, there will be no restore attempt either. Admittedly deleting them is a change indeed - well dunno right now, why you can't verify this, sorry.

07/07/11 22:18:29 changed by hasienda

  • status changed from assigned to closed.
  • resolution set to fixed.

(In [10393]) AccountManagerPlugin: Releasing version 0.3, pushing development to 0.4.

This new feature release finally propagates a number of solutions into an official release, after some time of testing with trunk, so explicitely closes #442, #816, #2966, #3989, #4160, #6821, #7111, #8534, #8549, #8663, #8813, #8892, #8925, #8936 and #8939.

Should have made this months ago, but felt so many pending issues were too bad for a new release. But it has been a tremendous ticket burndown since last year, so it's really worth considering an upgrade now. See fresh changelog for details.


Add/Change #8936 (Cannot delete user using AccountModule from web_ui)




Change Properties
Action