Modify

Opened 13 years ago

Closed 13 years ago

#8936 closed defect (fixed)

Cannot delete user using AccountModule from web_ui

Reported by: voithos Owned by: Steffen Hoffmann
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 (3)

delete_user.diff (1.0 KB) - added by voithos 13 years ago.
20110630_trac-log_user-delete.txt (2.6 KB) - added by Steffen Hoffmann 13 years ago.
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 13 years ago.

Download all attachments as: .zip

Change History (11)

Changed 13 years ago by voithos

Attachment: delete_user.diff added

Changed 13 years ago by Steffen Hoffmann

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

comment:1 Changed 13 years ago by Steffen Hoffmann

Status: newassigned

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.

comment:2 Changed 13 years ago by Steffen Hoffmann

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

Thanks to voithos for testing and reporting back.

comment:3 Changed 13 years ago by Steffen Hoffmann

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.

comment:4 Changed 13 years ago by Steffen Hoffmann

Summary: Cannot delete user using web_ui when running tracd on WindowsCannot 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.

comment:5 Changed 13 years ago by Steffen Hoffmann

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

Changed 13 years ago by voithos

comment:6 in reply to:  1 Changed 13 years ago 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.

comment:7 Changed 13 years ago by Steffen Hoffmann

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.

comment:8 Changed 13 years ago by Steffen Hoffmann

Resolution: fixed
Status: assignedclosed

(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.

Modify Ticket

Change Properties