Ticket #4125 (assigned defect)

Opened 8 months ago

Last modified 3 days ago

repr() of acct_mgr.web_ui.MessageWrapper is shown in the chrome notice bar instead of the notice HTML itself

Reported by: sroussey@network54.com Assigned to: pacopablo (accepted)
Priority: high Component: AccountManagerPlugin
Severity: critical Keywords:
Cc: davidfraser, mgood, lbruno@ename.pt, andrew.hardy@gl-group.com, thijs Trac Release: 0.11

Description

I enabled the account manager, so I get this warning <acct_mgr.web_ui.MessageWrapper? object at 0xa2a102c> and nothing else works. All pages give errors now:

In the admin area:

Error: Not Found No administration panels available

In wikis:

Trac Error Page WikiStart not found

etc, etc.

Attachments

acct_mgr-r4679-fix-messagewrapper.patch (3.0 kB) - added by otaku42 on 11/26/08 16:43:41.
accountmanagerplugin-r4831-fix-MessageWrapper.patch (1.0 kB) - added by quad on 11/28/08 06:19:21.
Fixes the notice/warning displayed regarding MessageWrapper
replaceMessageWrapper-with-genshi-markup-against-0.11-branch.patch (2.7 kB) - added by lbruno@ename.pt on 02/15/09 17:12:32.
Replace MessageWrapper? with genshi.Markup.

Change History

11/20/08 05:31:52 changed by anonymous

  • status changed from new to closed.
  • resolution set to worksforme.

Don't use the WebAdmin Plugins manager to select everything and you'll be OK.

(follow-up: ↓ 3 ) 11/20/08 20:09:43 changed by anonymous

  • status changed from closed to reopened.
  • resolution deleted.

I had the same problem and I found this site:

https://trac.ctdo.de/admin/ticket/111

I don't know German, but it has something to do with emails... so I've disabled the EmailVerificationModule component:

acct_mgr.web_ui.emailverificationmodule = disabled

and now it seems to work.

Some more details about this issue:

  • Trac 0.11.2.1
  • TracAccountManager 0.2.1dev-r3857
  • this problem happened only when I logged in as an authenticated user, without any special permissions (like TRAC_ADMIN for example), which was registered before upgrading from 0.11. When I created an account after upgrading to 0.11.2.1, I didn't see this problem. Also I didn't notice this problem when I was using my old account with TRAC_ADMIN (and many other) privileges.

So, to summarize, these settings didn't work for me:

acct_mgr.admin.* = enabled
acct_mgr.admin.accountmanageradminpage = enabled
acct_mgr.api.* = enabled
acct_mgr.htfile.* = enabled
acct_mgr.http.httpauthstore = enabled
acct_mgr.web_ui.* = enabled

and the following seems to be ok:

acct_mgr.admin.* = enabled
acct_mgr.admin.accountmanageradminpage = enabled
acct_mgr.api.* = enabled
acct_mgr.htfile.* = enabled
acct_mgr.http.httpauthstore = enabled
acct_mgr.web_ui.* = enabled
acct_mgr.web_ui.emailverificationmodule = disabled

(in reply to: ↑ 2 ; follow-up: ↓ 4 ) 11/21/08 08:27:56 changed by otaku42

Replying to anonymous:

I don't know German, but it has something to do with emails... so I've disabled the EmailVerificationModule component:

I had the same problem here, and your recipe worked for me as well.

However, my situation was different from that mentioned in the ticket description. My intention was to move a Trac instance from one server to another, and at the same time upgrade from Trac v0.10 to Trac v0.11. I've done such an upgrade before for another environment (as test case); since most of the parameters are similar in both environments I've simply copied the "test case" environment, adjusted trac.ini, replaced trac.db with that of the actual project and performed an upgrade for the database.

While it probably is not the cleanest way to perform such an upgrade, it worked for me. The only issue I ran into was the occurence of messages like that mentioned in the summary of this ticket, sometimes as warning, sometimes as info. Disabling the e-mail verification component fixed it.

Note: That issue did (and still does) not exist in the test case environment, which is hosted on the same server.

(in reply to: ↑ 3 ) 11/21/08 08:36:16 changed by otaku42

Replying to otaku42:

Note: That issue did (and still does) not exist in the test case environment, which is hosted on the same server.

Doh! Just checked my e-mail inbox and found the "Trac email verification" e-mail, and that rang a bell. Obviously, what happened is: when I logged in to the environment for the first time, the verification e-mail was sent. The "MessageWrapper? object" obviously intended to let me know that I need to confirm my e-mail address. Once I re-enabled the verification module and followed the instruction in the e-mail, the message disappeared.
And now I remember that I had similar fun with the test case environment.

From my point of view the only problem that remains to be fixed is that object information instead of the actual message gets displayed.

11/26/08 16:43:41 changed by otaku42

  • attachment acct_mgr-r4679-fix-messagewrapper.patch added.

11/26/08 17:36:40 changed by otaku42

I found out that the MessageWrapper? class is (at least in my case) not required at all - despite the comments that say something else. The attached patch fixes the reported issue for me, now the actual message rather (e.g. "Thank you for verifying your email address") gets displayed again instead of the information about the object type.

The patch has been tested with Trac 0.11.2, running on a Debian server with Apache 2.2, mod_wsgi and Python 2.5.

Despite the success in my case, this patch should probably regarded being nothing more than a work-around. It might well be that the original idea for introducing the MessageWrapper? class is still valid for other environments, in which case it would be better to fix MessageWrapper? rather than removing it. I'm still learning Python, but it appears to me that just the implementation of some magic member is missing.

11/26/08 17:47:27 changed by otaku42

NB: Just found that a similar patch has been attached to #3401 some days ago.

(follow-up: ↓ 12 ) 11/28/08 06:18:03 changed by quad

To fix the situation where the message in question is displayed, I've come up with a patch and the following procedure:

  1. Make sure all users are logged out of Trac.
  2. Use sqlite3 trac_env/db/trac.db on the server to clean the relevant table: DELETE FROM session; and DELETE FROM session_attribute.
  3. Apply the following patch and redeploy the .egg file to the plugins/ directory.
  4. Login again.

Rather than removing all occurrences of MessageWrapper in the code, the patch add a __str__() method to the MessageWrapper class, which is what was missing.

Also, the notice/warning message is displayed probably because somehow the email address field of the affected users was manipulated after the installation of this plugin. Therefore, session data is inserted in the database, but remains even after deinstallation/reinstallation of the plugin. Testing, logging in & logging out, then seems to confuse the plugin that's looking for a session attribute that shouldn't be there and an error is displayed.

Anyhow, check the second part of the patch. It's also only a workaround so the maintainer might want to fix it in a better way. Hope this helps.

11/28/08 06:19:21 changed by quad

  • attachment accountmanagerplugin-r4831-fix-MessageWrapper.patch added.

Fixes the notice/warning displayed regarding MessageWrapper

12/15/08 08:20:14 changed by frank@romeo-foxtrot.com

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

I met the similar problem twice. Previously, I simply deleted the user account and recreated another using the same user name. However, this time it didn't work. Finally, I resolved the problem by removing the records related to the user from session and session_attrI met the similar problem twice. Previously, I simply deleted the user account and recreated another using the same user name. However, this time it didn't work. Finally, I resolved the problem by removing the records related to the user from session and session_attribute. I didn't remove records belonged to other users.bute. I didn't remove records belonged to other users.

12/15/08 08:21:54 changed by frank@romeo-foxtrot.com

(sorry i pasted the content twice) I met the similar problem twice. Previously, I simply deleted the user account and recreated another using the same user name. However, this time it didn't work. Finally, I resolved the problem by removing the records related to the user from session and session_attribute. I didn't remove records belonged to other users.

12/18/08 07:39:45 changed by anonymous

  • status changed from closed to reopened.
  • resolution deleted.

I'm having a problem where new users are confirming their email and receiving this message.

trac-admin permission /var/local/trac/project list username is showing that they are infact granted the expected permissions. But these users are still reporting that they cannot edit the wiki or create tickets. I tried deleting their accounts from within the trac manager and having them re-register. to no avail.

in the course of our project we have upgraded from 0.10 to 11.1 to 0.11.2.1 and are using mysql.

12/26/08 11:21:47 changed by anonymous

when "Force users to change passwords after a password reset? " set to "Yes", a user will get a message: "Warning: <acct_mgr.web_ui.MessageWrapper? object at 0x01552990> " in a yellow box,

and after he changed his password, he will get a message like : "Warning: <acct_mgr.web_ui.MessageWrapper? object at 0x0160DAD1> " in a green box.

(in reply to: ↑ 7 ) 01/27/09 04:39:23 changed by anonymous

Replying to quad:

To fix the situation where the message in question is displayed, I've come up with a patch and the following procedure: 1. Make sure all users are logged out of Trac. 1. Use sqlite3 trac_env/db/trac.db on the server to clean the relevant table: DELETE FROM session; and DELETE FROM session_attribute. 1. Apply the following patch and redeploy the .egg file to the plugins/ directory. 1. Login again. Rather than removing all occurrences of MessageWrapper in the code, the patch add a __str__() method to the MessageWrapper class, which is what was missing.

The patch you attached indeed fixed that. However, for some reason the contents of the box is not rendered as HTML. It is escaped instead. I could not find where that happened exactly.

01/30/09 10:00:10 changed by davidfraser

  • cc set to davidfraser.

(follow-up: ↓ 16 ) 02/15/09 17:03:25 changed by lbruno@ename.pt

  • cc changed from davidfraser to davidfraser, mgood, lbruno@ename.pt.
  • priority changed from normal to high.
  • severity changed from major to critical.
  • summary changed from acct_mgr.web_ui.MessageWrapper object at 0xa2a102c to repr() of acct_mgr.web_ui.MessageWrapper is shown in the chrome notice bar instead of the notice HTML itself.

I've replaced MessageWrapper? with genshi.Markup, tested this by "forgetting my password" in the HTML auth form. It worked as I expected; I'd venture MessageWrapper? is no longer needed: an artifact of an ancient era.

The email verification problem is just an obnoxious red-herring; you won't have any panels available (even being TRAC_ADMIN) until you /verify_email.

02/15/09 17:12:32 changed by lbruno@ename.pt

  • attachment replaceMessageWrapper-with-genshi-markup-against-0.11-branch.patch added.

Replace MessageWrapper? with genshi.Markup.

02/15/09 17:19:07 changed by lbruno@ename.pt

I've taken otaku42's patch and added genshi.Markup to exclude that text from the escaping. As far as I can see, development happens against the 0.11/ branch, not in trunk/; the patch probably applies cleanly to both.

Notice The email field is directly shown, unescaped, from the session's value. I'm not sure if this is actually a problem, but I'd appreciate opinions.

(in reply to: ↑ 14 ; follow-up: ↓ 17 ) 02/16/09 03:40:35 changed by mgood

Replying to lbruno@ename.pt:

I've replaced MessageWrapper? with genshi.Markup, tested this by "forgetting my password" in the HTML auth form. It worked as I expected; I'd venture MessageWrapper? is no longer needed: an artifact of an ancient era.

No, not really that ancient. Trac 0.11.2 made the hack unnecessary, but I'm sure if I just remove it I'll get plenty of bug reports when people install it on a slightly older Trac version and it breaks there, so I'm debating about the right fix.

(in reply to: ↑ 16 ) 02/16/09 09:50:52 changed by anonymous

Replying to mgood:

I've replaced MessageWrapper? with genshi.Markup

I'm sure if I just remove it I'll get plenty of bug reports

I was suspecting that. Inheriting from genshi.Markup seemed safer. I wasn't sure if MessageWrapper?'s interface was already implemented in Markup, but I assumed it would work anyway.

I hadn't tested it yet, but I just did: I have a 0.11.1, and it works with genshi.Markup. My 0.11.1 is in production, not the cleanest checkout; holler if you need me to test a specific revision.

02/20/09 17:23:40 changed by lbruno@ename.pt

  • owner changed from pacopablo to mgood.
  • status changed from reopened to new.

I'm now running this on 0.11.3. Nothing broken.

03/16/09 17:19:23 changed by lbruno@ename.pt

  • owner changed from mgood to pacopablo.

It's a bit boring to get bitten once again by this, on a new Trac instance. Won't anyone take this up, please? Neither the 0.11/ branch nor trunk/ has this committed.

03/31/09 22:40:44 changed by anonymous

Yes. I've just downloaded the last trac, and arrived here, searching for this error message won't someone pls commit?

(follow-up: ↓ 22 ) 03/31/09 22:44:33 changed by pacopablo

  • status changed from new to assigned.

I apologize for the delay on this. I will be committing the replaceMessageWrapper-with-genshi-markup-against-0.11-branch.patch in the next couple days.

(in reply to: ↑ 21 ) 03/31/09 23:58:29 changed by lbruno@ename.pt

Replying to pacopablo:

I apologize for the delay on this. I will be committing the replaceMessageWrapper-with-genshi-markup-against-0.11-branch.patch in the next couple days.

As I've said earlier, the email field is directly shown, unescaped, from the session's value. I'm not sure if this is actually a problem, probably not. But I can trust my users' input (_).

Thank you for looking into this!

04/01/09 00:02:56 changed by lbruno@ename.pt

And thank you too, otaku42! You pointed me in the right direction.

04/03/09 21:24:01 changed by pacopablo

committed patch in [5478]

05/28/09 08:36:00 changed by manski

Yep - but you forgot to patch the 0.11 branch.

05/29/09 17:17:01 changed by jasondavies

Yep, you need to patch 0.11 too, the patch works great for me.

06/03/09 11:46:26 changed by anonymous

  • cc changed from davidfraser, mgood, lbruno@ename.pt to davidfraser, mgood, lbruno@ename.pt, andrew.hardy@gl-group.com.

(follow-up: ↓ 30 ) 06/23/09 00:55:37 changed by anonymous

confirmed, still a problem on 0.11 branch

06/26/09 14:18:29 changed by thijs

  • cc changed from davidfraser, mgood, lbruno@ename.pt, andrew.hardy@gl-group.com to davidfraser, mgood, lbruno@ename.pt, andrew.hardy@gl-group.com, thijs.

I've seen this error as well and I believe it was in the trunk version, but I'll have to double check and confirm.

(in reply to: ↑ 28 ) 07/01/09 17:56:46 changed by anonymous

Replying to anonymous:

confirmed, still a problem on 0.11 branch

yup


Add/Change #4125 (repr() of acct_mgr.web_ui.MessageWrapper is shown in the chrome notice bar instead of the notice HTML itself)




Change Properties
Action