Opened 16 years ago
Closed 14 years ago
#4040 closed defect (fixed)
[patch] TracError instance has no attribute 'acctmgr' on new user creation
Reported by: | Owned by: | Steffen Hoffmann | |
---|---|---|---|
Priority: | normal | Component: | AccountManagerPlugin |
Severity: | major | Keywords: | unicode change notify |
Cc: | Matt Callaghan, waifunlee@…, mcpbalaji@… | Trac Release: | 0.12 |
Description
Hi,
I am using TracAccountManager 0.2.1dev-r4679 with Trac 0.11.1 and for some reason the create new user feature is broken.
Trac detected an internal error: AttributeError: TracError instance has no attribute 'acctmgr'
Python Traceback
Most recent call last: File "/usr/lib/python2.4/site-packages/trac/web/main.py", line 423, in _dispatch_request File "/usr/lib/python2.4/site-packages/trac/web/main.py", line 197, in dispatch File "/usr/lib/python2.4/site-packages/trac/admin/web_ui.py", line 113, in process_request File "build/bdist.linux-x86_64/egg/acct_mgr/admin.py", line 116, in render_admin_panel File "build/bdist.linux-x86_64/egg/acct_mgr/admin.py", line 187, in _do_users
System Information:
User Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Chrome/0.3.154.9 Safari/525.19
Trac: 0.11.1 Python: 2.4.3 (#1, May 24 2008, 13:57:05) [GCC 4.1.2 20070626 (Red Hat 4.1.2-14)] setuptools: 0.6c9 SQLite: 3.3.6 pysqlite: 1.1.7 Genshi: 0.5.1 Pygments: 0.11.1 Subversion: 1.5.4 (r33841) jQuery: 1.2.6
Thanks! -Aaron
Attachments (5)
Change History (42)
comment:1 follow-up: 2 Changed 16 years ago by
comment:2 Changed 16 years ago by
Trac Release: | 0.10 → 0.11 |
---|
Replying to waifunlee@gmail.com:
Turns out the problem was I was using htdigest for the AccountManager to do authentication. And it seems that I need to add the username to the htdigest file before I can edit the new user. Not sure if I am missing any setup steps.
-Aaron
Is this valid? (seems stupid to anonymously ask questions, huh?) I can reproduce this. Here is the relevant part of my config file, I think:
[components] acct_mgr.* = enabled acct_mgr.admin.accountmanageradminpage = enabled acct_mgr.web_ui.accountmodule = enabled acct_mgr.web_ui.emailverificationmodule = disabled acct_mgr.web_ui.loginmodule = enabled acct_mgr.web_ui.registrationmodule = disabled
I had been creating the users by hand. I still will, I guess. That's cool. The point is, now they can set new passwords (not yet tested) from within Trac. Yay! It feels more right that way.
(Don't call it irrelevant, I just provided a use case and some configuration information!)
Here's the boring bit:
Trac detected an internal error: AttributeError: TracError instance has no attribute 'acctmgr' If you think this should work you can reproduce the problem, you should consider reporting this to the Trac team. Before you do that, though, please first try searching for similar issues, as it is quite likely that this problem has been reported before. For questions about installation and configuration of Trac, please try the mailing list instead of filing a ticket. Otherwise, please ==== How to Reproduce ==== While doing a POST operation on `/admin/accounts/users`, Trac issued an internal error. ''(please provide additional details here)'' Request parameters: {{{ {'__FORM_TOKEN': u'cf910bf494611404b07d5e4f', 'add': u' Add ', 'cat_id': u'accounts', 'email': u'cherry@sneakywhoami.biz', 'name': u'Cherry', 'panel_id': u'users', 'password': u'Jono3011', 'password_confirm': u'Jono3011', 'path_info': None, 'user': u'Cherry'} }}} User Agent was: `Mozilla/5.0 (Windows; U; Windows NT 5.0; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3` ==== System Information ==== || '''Trac''' || `0.11.1` || || '''Python''' || `2.4.3 (#1, Mar 14 2007, 18:51:08) ` [[br]] `[GCC 4.1.1 20070105 (Red Hat 4.1.1-52)]` || || '''setuptools''' || `0.6c5` || || '''SQLite''' || `3.3.6` || || '''pysqlite''' || `1.1.7` || || '''Genshi''' || `0.5.1` || || '''mod_python''' || `3.3.1` || || '''Pygments''' || `0.11.1` || || '''Subversion''' || `1.4.4 (r25188)` || || '''jQuery:''' || `1.2.6` || ==== Python Traceback ==== {{{ Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/Trac-0.11.1-py2.4.egg/trac/web/main.py", line 423, in _dispatch_request dispatcher.dispatch(req) File "/usr/lib/python2.4/site-packages/Trac-0.11.1-py2.4.egg/trac/web/main.py", line 197, in dispatch resp = chosen_handler.process_request(req) File "/usr/lib/python2.4/site-packages/Trac-0.11.1-py2.4.egg/trac/admin/web_ui.py", line 113, in process_request path_info) File "build/bdist.linux-i686/egg/acct_mgr/admin.py", line 116, in render_admin_panel File "build/bdist.linux-i686/egg/acct_mgr/admin.py", line 187, in _do_users AttributeError: TracError instance has no attribute 'acctmgr' !}}} a new ticket at the Trac project site, where you can describe the problem and explain how to reproduce it. Python Traceback Most recent call last: * File "/usr/lib/python2.4/site-packages/Trac-0.11.1-py2.4.egg/trac/web/main.py", line 423, in _dispatch_request Code fragment: 418. try: 419. if not env and env_error: 420. raise HTTPInternalError(env_error) 421. try: 422. dispatcher = RequestDispatcher(env) 423. dispatcher.dispatch(req) 424. except RequestDone: 425. pass 426. resp = req._response or [] 427. 428. except HTTPException, e: Local variables: Name Value after [u' except RequestDone:', u' pass', u' resp = ... before [u' try:', u' if not env and env_error:', u' raise ... dispatcher <trac.web.main.RequestDispatcher object at 0xa21ed4c> e <exceptions.AttributeError instance at 0xa21ed6c> env <trac.env.Environment object at 0x9d108ec> env_error None exc_info (<class exceptions.AttributeError at 0x9a3474c>, ... filename '/usr/lib/python2.4/site-packages/Trac-0.11.1-py2.4.egg/trac/web/main.py' frames [{'function': '_dispatch_request', 'lines_before': [u' try:', u' ... has_admin True line u' dispatcher.dispatch(req)' lineno 422 message u"AttributeError: TracError instance has no attribute 'acctmgr'" req <Request "POST u'/admin/accounts/users'"> resp [] tb <traceback object at 0xa2eaa2c> tb_hide None traceback 'Traceback (most recent call last):\n File ... * File "/usr/lib/python2.4/site-packages/Trac-0.11.1-py2.4.egg/trac/web/main.py", line 197, in dispatch Code fragment: 192. req.args.get('__FORM_TOKEN') != req.form_token: 193. raise HTTPBadRequest('Missing or invalid form token. ' 194. 'Do you have cookies enabled?') 195. 196. # Process the request and render the template 197. resp = chosen_handler.process_request(req) 198. if resp: 199. if len(resp) == 2: # Clearsilver 200. chrome.populate_hdf(req) 201. template, content_type = \ 202. self._post_process_request(req, *resp) Local variables: Name Value chosen_handler <trac.admin.web_ui.AdminModule object at 0xa21ee6c> chrome <trac.web.chrome.Chrome object at 0xa1359ac> ctype 'application/x-www-form-urlencoded' err (<class exceptions.AttributeError at 0x9a3474c>, ... handler <trac.admin.web_ui.AdminModule object at 0xa21ee6c> options {} req <Request "POST u'/admin/accounts/users'"> self <trac.web.main.RequestDispatcher object at 0xa21ed4c> * File "/usr/lib/python2.4/site-packages/Trac-0.11.1-py2.4.egg/trac/admin/web_ui.py", line 113, in process_request Code fragment: 108. if not provider: 109. raise HTTPNotFound(_('Unknown administration panel')) 110. 111. if hasattr(provider, 'render_admin_panel'): 112. template, data = provider.render_admin_panel(req, cat_id, panel_id, 113. path_info) 114. 115. else: # support for legacy WebAdmin panels 116. data = {} 117. cstmpl, ct = provider.process_admin_request(req, cat_id, panel_id, 118. path_info) Local variables: Name Value _panel_order <function _panel_order at 0xa2ec95c> cat_id u'accounts' panel_id u'users' panels [('general', 'General', 'basics', 'Basic Settings'), ('general', ... path_info None provider <acct_mgr.admin.AccountManagerAdminPage object at 0xa2eb86c> providers {('repository_hooks', 'post-commit'): ... req <Request "POST u'/admin/accounts/users'"> self <trac.admin.web_ui.AdminModule object at 0xa21ee6c> * File "build/bdist.linux-i686/egg/acct_mgr/admin.py", line 116, in render_admin_panel Local variables: Name Value cat u'accounts' page u'users' path_info None req <Request "POST u'/admin/accounts/users'"> self <acct_mgr.admin.AccountManagerAdminPage object at 0xa2eb86c> * File "build/bdist.linux-i686/egg/acct_mgr/admin.py", line 187, in _do_users Local variables: Name Value create_enabled True data {'create_enabled': True, 'delete_enabled': True, 'registration_error': ... delete_enabled True e <trac.core.TracError instance at 0xa2ebeac> listing_enabled True password_change_enabled True perm <trac.perm.PermissionSystem object at 0xa2eb90c> req <Request "POST u'/admin/accounts/users'"> self <acct_mgr.admin.AccountManagerAdminPage object at 0xa2eb86c> File "/usr/lib/python2.4/site-packages/Trac-0.11.1-py2.4.egg/trac/web/main.py", line 423, in _dispatch_request dispatcher.dispatch(req) File "/usr/lib/python2.4/site-packages/Trac-0.11.1-py2.4.egg/trac/web/main.py", line 197, in dispatch resp = chosen_handler.process_request(req) File "/usr/lib/python2.4/site-packages/Trac-0.11.1-py2.4.egg/trac/admin/web_ui.py", line 113, in process_request path_info) File "build/bdist.linux-i686/egg/acct_mgr/admin.py", line 116, in render_admin_panelFile "build/bdist.linux-i686/egg/acct_mgr/admin.py", line 187, in _do_users System Information: User Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3 Trac: 0.11.1 Python: 2.4.3 (#1, Mar 14 2007, 18:51:08) [GCC 4.1.1 20070105 (Red Hat 4.1.1-52)] setuptools: 0.6c5 SQLite: 3.3.6 pysqlite: 1.1.7 Genshi: 0.5.1 mod_python: 3.3.1 Pygments: 0.11.1 Subversion: 1.4.4 (r25188) jQuery: 1.2.6
Some things to note:
- I'm not using ClearSilver, but Pygments
- I'm under mod_python
- I'm not using the form-based login ( yes, this means I should make a custom logout link to http://user:pass@example.com/trac/myproject/logout )
IFF it is a valid bug, then I hope this helps. If it's not a valid bug, I feel like an idiot for not understanding why I can't add users through the admin panel alone ;) can't read the stack trace easily because I don't yet fluently speak Python.
comment:3 Changed 16 years ago by
I'm also receiving this error when trying to create a user:
Trac detected an internal error
AttributeError: 'TracError' object has no attribute 'acctmgr'
Python Traceback
File "/usr/lib/python2.5/site-packages/Trac-0.11.2.1-py2.5.egg/trac/web/main.py", line 432, in _dispatch_request dispatcher.dispatch(req) File "/usr/lib/python2.5/site-packages/Trac-0.11.2.1-py2.5.egg/trac/web/main.py", line 204, in dispatch resp = chosen_handler.process_request(req) File "/usr/lib/python2.5/site-packages/Trac-0.11.2.1-py2.5.egg/trac/admin/web_ui.py", line 113, in process_request path_info) File "/usr/lib/python2.5/site-packages/TracAccountManager-0.2.1dev_r4679-py2.5.egg/acct_mgr/admin.py", line 116, in render_admin_panelFile "/usr/lib/python2.5/site-packages/TracAccountManager-0.2.1dev_r4679-py2.5.egg/acct_mgr/admin.py", line 187, in _do_users
System Information
Trac: | 0.11.2.1 |
Python: | 2.5.2 (r252:60911, Jul 31 2008, 17:44:49) [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] |
setuptools: | 0.6c8 |
SQLite: | 3.4.2 |
pysqlite: | 2.3.2 |
Genshi: | 0.6dev-r960 |
Subversion: | 1.4.6 (r28521) |
jQuery: | 1.2.6 |
Relevant Configuration Files
trac.ini:
[account-manager] htdigest_realm = trac password_file = /usr/local/trac/user-auth.htaccess password_format = htdigest password_store = HtDigestStore [components] acct_mgr.admin.accountmanageradminpage = enabled acct_mgr.api.accountmanager = enabled acct_mgr.htfile.htdigeststore = enabled acct_mgr.web_ui.accountmodule = enabled acct_mgr.web_ui.registrationmodule = disabled
comment:4 Changed 16 years ago by
PS: I'm also running the same version of AccountManagerPlugin as waifunlee. TracAccountManager-0.2.1dev_r4679-py2.5.egg
comment:5 Changed 16 years ago by
Cc: | Matt Callaghan Matt Good added; anonymous removed |
---|
comment:6 follow-up: 31 Changed 16 years ago by
Cc: | waifunlee@… added; Matt Good removed |
---|
SOLVED: When I tried to delete a user it told me that trac needed read/write permissions on not only the user-auth file, but also the parent directory of this file.
Giving read/write to the parent (containing) directory of the htdigest.user-auth file (in my case /usr/local/trac/user-auth.htaccess), eliminated this error!
waifunlee, please confirm for yourself also.
comment:8 Changed 16 years ago by
Priority: | normal → high |
---|
Replying to waifunlee@gmail.com:
I think it's been fixed.
Not in the repo ;)
Internal error in admin.py L 187:
except TracError, e: data['registration_error'] = e.message data['acctmgr'] = e.acctmgr # Oops! <====
Should be:
... ... data['acctmgr'] = getattr(e, 'acctmgr', '')
Changed 16 years ago by
Attachment: | acct_mgr.diff added |
---|
comment:12 Changed 15 years ago by
i'm still getting the same error.. below is the system information:
System Information:
User Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.1) Gecko/20090715 Firefox/3.5.1 (.NET CLR 3.5.30729) Trac: 0.11.5 Python: 2.4.3 (#1, Jan 21 2009, 01:11:33) [GCC 4.1.2 20071124 (Red Hat 4.1.2-42)] setuptools: 0.6c9 MySQL: server: "5.0.45", client: "5.0.45", thread-safe: 0 MySQLdb: 1.2.3c1 Genshi: 0.5.1 mod_python: 3.2.8 Pygments: 1.0 jQuery: 1.2.6
Can somebody please help, where do i need to apply this diff? I looked all through the installation, couldnot locate an admin.py file with piece of code similar to mentioned above. I went to the trac projects directory's .egg-cache folder but there i see template htmls. I went to /usr/lib/python2.4/site-packages/ folder but there i just see the TracAccountManager-0.2.1dev_r5836-py2.4.egg file; no extracted directory for the .egg file. I'm new to python and .egg concepts; sure i'm misssing something very obvious. Please help.
Thanks, -Sumit
comment:13 Changed 15 years ago by
ahh.. so i figured out finally by downloading everything from the svn, there is an admin.py file as <SVNROOT>/acct_mgr/admin.py. After making those changes, i did easy_install file://<SVNROOT> and things are working.
cool guys, its awesome! :)
Changed 15 years ago by
Attachment: | missing_attribute_due_to_typo.patch added |
---|
This is the correct patch - the error happens due to typo
comment:14 Changed 15 years ago by
How to Reproduce
While doing a POST operation on /admin/accounts/users
, Trac issued an internal error.
If I try to create an useraccount I get this error. I added both patches to AccountManagerPlugin and even installed the plugin again. But nothing changed.
Request parameters:
{'__FORM_TOKEN': u'bc18142f660bee770bf3a6bb', 'add': u' Add ', 'cat_id': u'accounts', 'email': u'user@example.com', 'name': u'name', 'panel_id': u'users', 'password': u'secret', 'password_confirm': u'secret', 'path_info': None, 'user': u'andi'}
User Agent was: Mozilla/5.0 (X11; U; Linux i686; de; rv:1.9.0.14) Gecko/2009090216 Ubuntu/9.04 (jaunty) Firefox/3.0.14
System Information
Trac | 0.11.5
|
Python | 2.4.3 (#1, Jul 27 2009, 17:57:39) [GCC 4.1.2 20080704 (Red Hat 4.1.2-44)]
|
setuptools | 0.6c7
|
SQLite | 3.3.6
|
pysqlite | 1.1.7
|
Genshi | 0.5.1
|
mod_python | 3.2.8
|
Subversion | 1.4.2 (r22196)
|
jQuery: | 1.2.6
|
Python Traceback
Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/Trac-0.11.5-py2.4.egg/trac/web/main.py", line 444, in _dispatch_request dispatcher.dispatch(req) File "/usr/lib/python2.4/site-packages/Trac-0.11.5-py2.4.egg/trac/web/main.py", line 205, in dispatch resp = chosen_handler.process_request(req) File "/usr/lib/python2.4/site-packages/Trac-0.11.5-py2.4.egg/trac/admin/web_ui.py", line 114, in process_request path_info) File "build/bdist.linux-i686/egg/acct_mgr/admin.py", line 117, in render_admin_panel File "build/bdist.linux-i686/egg/acct_mgr/admin.py", line 188, in _do_users AttributeError: TracError instance has no attribute 'acctmgr'
comment:15 Changed 15 years ago by
Resolution: | → worksforme |
---|---|
Severity: | normal → major |
Status: | new → closed |
I can confirm the bug, and I can confirm that the proposed path works for me. Applying missing_attribute_due_to_typo.patch to the SVN version of the plugin (not yet fixed upstream) fixes the problem.
Beware, the acct_mgr.diff don't fix the problem, just hide it.
Cheers
comment:16 Changed 15 years ago by
Resolution: | worksforme |
---|---|
Status: | closed → reopened |
Sorry, didn't want to close it, not until get fixed on the trunk.
Cheers
comment:17 Changed 15 years ago by
Sorry, again, it's fixed on the trunk (I think, code is totally different). I would prefer that they fix the 0.11 branch.
Cheers.
comment:19 Changed 15 years ago by
This bug is STILL not fixed in trunk. The patch above does not fix it. I have downloaded and built the latest from trunk (7165) and this bug is still occurring.
The following patch is required:
except TracError, e:
dataregistration_error? = e.message dataacctmgr? = e.acctmgr # Oops! <====
Should be:
...
... dataacctmgr? = getattr(e, 'acctmgr', )
This fixes the bug, I just verified this fixes the problem. Someone should fix it in trunk.
comment:20 Changed 15 years ago by
Sorry, again forgot to format:
The following patch is required in admin.py, as noted above:
except TracError, e: data['registration_error'] = e.message data['acctmgr'] = e.acctmgr # Oops! <====
Should be:
... ... data['acctmgr'] = getattr(e, 'acctmgr', '')
comment:21 follow-up: 22 Changed 15 years ago by
@havok: can you please explain what do you mean by:
"Beware, the acct_mgr.diff don't fix the problem, just hide it. "?
There was no typo in my copy, which came with FC11:
trac-accountmanager-plugin-0.2.1-0.3.20090522svn5836.fc11.noarch
Applying the patch seemed to fix the problem.
Thanks.
comment:22 follow-up: 23 Changed 15 years ago by
Replying to anonymous:
@havok: can you please explain what do you mean by:
"Beware, the acct_mgr.diff don't fix the problem, just hide it. "?
Check this:
http://effbot.org/zone/python-getattr.htm
getattr(e, 'acctmgr') = e.acctmgr
The problem is not that the attribute doesn't exists, the problem is that is not correctly called. If you add the getattr(e, 'acctmgr', ) you're saying: if the attribute doesn't exists, do nothing, with obviously doesn't fix the problem, just hide it.
Cheers
comment:23 Changed 15 years ago by
Well.. my English is not perfect. What I want to say is that the typo is the bug, because the attribute is created with another name (not the correcto one). The correct fix is to fix the attribute to the correct name when is created, not to ask later if it exists, and if not, do nothing. That doesn't solve the problem, just hide it.
Cheers
comment:24 Changed 15 years ago by
I solved the problem by following the instructions on http://trac-hacks.org/wiki/AccountManagerPlugin. I'm using HtPasswdStore:
; the file where user accounts are stored ; the webserver will need write permissions to this file ; and its parent folder
Hope this helps!
comment:25 follow-up: 26 Changed 14 years ago by
Problem at least for me was outside of account manager, but in notify. I have a non-ascii character in the site description which enters the email to be sent for new user creation.
I got basically the traceback from http://trac-hacks.org/ticket/4040#comment:14 except the _do_users call is now in line 191.
AccountManager assumes that all TracErrors have an acctmgr attribute, which is not the case for the TracError raised by notifiy and most probably most other TracErrors.
Attached is a patch that fixes this, with a comment to indicate why it is ok, if there is no acctmgt attribute (0001-not-fail-on-foreign-TracError-without-.acctmgr.patch)
I am using it with Trac 0.12.
Changed 14 years ago by
Attachment: | 0001-not-fail-on-foreign-TracError-without-.acctmgr.patch added |
---|
comment:26 Changed 14 years ago by
I reproduce the problem as chaoflow describes when I use Trac 0.12 too. And I found it is because some Chinese characters are added in the project's description in the Admin page. If I delete the Chinese characters, the problem is solved.
The exact position that Chinese characters are added is "管理—>一般—>基础设置—>描述"; I guess in English it is in "Admin—>General—>Basic—>Description".
Hope this could help to trace the problem.
comment:27 Changed 14 years ago by
Hi, I found the same error in local instance, so I put a pdb inside the _create_user method in the web_ui.py file.
The attribute error is because the raised exception is not fired by the _create_user method insted is fired when it try to set the password.
mgr.set_password(user, password) # in the web_ui.py module, line 69.
But after to go a bit more deep, I found that the real problem is the mimetype encoding used when the notification is send.
Here is the log.
> /usr/local/trac/eggs/TracAccountManager-0.2.1dev_r4679-py2.6.egg/acct_mgr/web_ui.py(36)_create_user() -> user = req.args.get('user') (Pdb) (Pdb) l 31 32 def _create_user(req, env, check_permissions=True): 33 mgr = AccountManager(env) 34 import pdb;pdb.set_trace() 35 36 -> user = req.args.get('user') 37 name = req.args.get('name') 38 email = req.args.get('email') 39 acctmgr = {'username' : user, 40 'name' : name, 41 'email' : email, (Pdb) n > /usr/local/trac/eggs/TracAccountManager-0.2.1dev_r4679-py2.6.egg/acct_mgr/web_ui.py(37)_create_user() -> name = req.args.get('name') (Pdb) n > /usr/local/trac/eggs/TracAccountManager-0.2.1dev_r4679-py2.6.egg/acct_mgr/web_ui.py(38)_create_user() -> email = req.args.get('email') (Pdb) n > /usr/local/trac/eggs/TracAccountManager-0.2.1dev_r4679-py2.6.egg/acct_mgr/web_ui.py(39)_create_user() -> acctmgr = {'username' : user, (Pdb) n > /usr/local/trac/eggs/TracAccountManager-0.2.1dev_r4679-py2.6.egg/acct_mgr/web_ui.py(40)_create_user() -> 'name' : name, (Pdb) n > /usr/local/trac/eggs/TracAccountManager-0.2.1dev_r4679-py2.6.egg/acct_mgr/web_ui.py(41)_create_user() -> 'email' : email, (Pdb) n > /usr/local/trac/eggs/TracAccountManager-0.2.1dev_r4679-py2.6.egg/acct_mgr/web_ui.py(43)_create_user() -> error = TracError('') (Pdb) n > /usr/local/trac/eggs/TracAccountManager-0.2.1dev_r4679-py2.6.egg/acct_mgr/web_ui.py(44)_create_user() -> error.acctmgr = acctmgr (Pdb) n > /usr/local/trac/eggs/TracAccountManager-0.2.1dev_r4679-py2.6.egg/acct_mgr/web_ui.py(45)_create_user() -> if not user: (Pdb) pp error.acctmgr {'email': u'juan@linux.org.ar', 'name': u'Juan A. Diaz', 'username': u'nueces'} (Pdb) n > /usr/local/trac/eggs/TracAccountManager-0.2.1dev_r4679-py2.6.egg/acct_mgr/web_ui.py(49)_create_user() -> if mgr.has_user(user): (Pdb) n > /usr/local/trac/eggs/TracAccountManager-0.2.1dev_r4679-py2.6.egg/acct_mgr/web_ui.py(53)_create_user() -> if check_permissions: (Pdb) n > /usr/local/trac/eggs/TracAccountManager-0.2.1dev_r4679-py2.6.egg/acct_mgr/web_ui.py(61)_create_user() -> password = req.args.get('password') (Pdb) n > /usr/local/trac/eggs/TracAccountManager-0.2.1dev_r4679-py2.6.egg/acct_mgr/web_ui.py(62)_create_user() -> if not password: (Pdb) n > /usr/local/trac/eggs/TracAccountManager-0.2.1dev_r4679-py2.6.egg/acct_mgr/web_ui.py(66)_create_user() -> if password != req.args.get('password_confirm'): (Pdb) n > /usr/local/trac/eggs/TracAccountManager-0.2.1dev_r4679-py2.6.egg/acct_mgr/web_ui.py(70)_create_user() -> mgr.set_password(user, password) (Pdb) n TracError: TracErro...etting',) > /usr/local/trac/eggs/TracAccountManager-0.2.1dev_r4679-py2.6.egg/acct_mgr/web_ui.py(70)_create_user() -> mgr.set_password(user, password) (Pdb) l 65 66 if password != req.args.get('password_confirm'): 67 error.message = 'The passwords must match.' 68 raise error 69 70 -> mgr.set_password(user, password) 71 72 db = env.get_db_cnx() 73 cursor = db.cursor() 74 cursor.execute("SELECT count(*) FROM session " 75 "WHERE sid=%s AND authenticated=1", (Pdb) n --Return-- > /usr/local/trac/eggs/TracAccountManager-0.2.1dev_r4679-py2.6.egg/acct_mgr/web_ui.py(70)_create_user()->None -> mgr.set_password(user, password) (Pdb) l 65 66 if password != req.args.get('password_confirm'): 67 error.message = 'The passwords must match.' 68 raise error 69 70 -> mgr.set_password(user, password) 71 72 db = env.get_db_cnx() 73 cursor = db.cursor() 74 cursor.execute("SELECT count(*) FROM session " 75 "WHERE sid=%s AND authenticated=1", (Pdb) n TracError: TracErro...etting',) > /usr/local/trac/eggs/TracAccountManager-0.2.1dev_r4679-py2.6.egg/acct_mgr/admin.py(184)_do_users() -> _create_user(req, self.env, check_permissions=False) (Pdb) l 179 180 if req.method == 'POST': 181 if req.args.get('add'): 182 if create_enabled: 183 try: 184 -> _create_user(req, self.env, check_permissions=False) 185 except TracError, e: 186 data['registration_error'] = e.message 187 data['acctmgr'] = e.acctmgr 188 else: 189 data['registration_error'] = 'The password store does ' \ (Pdb) n > /usr/local/trac/eggs/TracAccountManager-0.2.1dev_r4679-py2.6.egg/acct_mgr/admin.py(185)_do_users() -> except TracError, e: (Pdb) n > /usr/local/trac/eggs/TracAccountManager-0.2.1dev_r4679-py2.6.egg/acct_mgr/admin.py(186)_do_users() -> data['registration_error'] = e.message (Pdb) n > /usr/local/trac/eggs/TracAccountManager-0.2.1dev_r4679-py2.6.egg/acct_mgr/admin.py(187)_do_users() -> data['acctmgr'] = e.acctmgr (Pdb) n AttributeError: "'TracError' object has no attribute 'acctmgr'" > /usr/local/trac/eggs/TracAccountManager-0.2.1dev_r4679-py2.6.egg/acct_mgr/admin.py(187)_do_users() -> data['acctmgr'] = e.acctmgr (Pdb) e TracError('Ticket contains non-ASCII chars. Please change encoding setting',)
In the log.trac in DEBUG mode this message is registered.
010-07-26 09:12:12,457 Trac[api] INFO: Created new user: nueces
Whit the pdb inside of the api.py in the set_password method, I found that the exception is raised by the self._notify('created', user, password) method in the line 129 of the original file, and number 130 with the pdb.
> /usr/local/trac/eggs/TracAccountManager-0.2.1dev_r4679-py2.6.egg/acct_mgr/api.py(122)set_password() -> store = self.find_user_store(user) (Pdb) l 117 continue 118 return exists 119 120 def set_password(self, user, password): 121 import pdb;pdb.set_trace() 122 -> store = self.find_user_store(user) 123 if store and not hasattr(store, 'set_password'): 124 raise TracError('The authentication backend for the user, %s, ' 125 'does not support setting the password' % user) 126 elif not store: 127 store = self.get_supporting_store('set_password') [...] > /usr/local/trac/eggs/TracAccountManager-0.2.1dev_r4679-py2.6.egg/acct_mgr/api.py(130)set_password() -> self._notify('created', user, password) (Pdb) n TracError: TracErro...etting',) > /usr/local/trac/eggs/TracAccountManager-0.2.1dev_r4679-py2.6.egg/acct_mgr/api.py(130)set_password() -> self._notify('created', user, password) (Pdb) self._notify('created', user, password) *** TracError: Ticket contains non-ASCII chars. Please change encoding setting
And now with the pdb inside of the notification.py
> /usr/local/trac/eggs/TracAccountManager-0.2.1dev_r4679-py2.6.egg/acct_mgr/notification.py(135)send() -> if not self._charset.body_encoding: (Pdb) l 130 if pcc: 131 headers['Cc'] = ', '.join(pcc) 132 headers['Date'] = formatdate() 133 # sanity check 134 import pdb;pdb.set_trace() 135 -> if not self._charset.body_encoding: 136 try: 137 dummy = body.encode('ascii') 138 except UnicodeDecodeError: 139 raise TracError(_("Ticket contains non-ASCII chars. " \ 140 "Please change encoding setting")) (Pdb) self._charset.body_encoding None (Pdb) n > /usr/local/trac/eggs/TracAccountManager-0.2.1dev_r4679-py2.6.egg/acct_mgr/notification.py(136)send() -> try: (Pdb) n > /usr/local/trac/eggs/TracAccountManager-0.2.1dev_r4679-py2.6.egg/acct_mgr/notification.py(137)send() -> dummy = body.encode('ascii') (Pdb) n UnicodeDecodeError: UnicodeD...ge(128)') > /usr/local/trac/eggs/TracAccountManager-0.2.1dev_r4679-py2.6.egg/acct_mgr/notification.py(137)send() -> dummy = body.encode('ascii') (Pdb) body.encode('ascii') *** UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 72: ordinal not in range(128) (Pdb) body 'New user registration for user nueces\n\n--\nGrupo de Relatividad y Gravitaci\xc3\xb3n <https://relatividad....>\nRelatividad y Gravitaci\xc3\xb3n\n\n' (Pdb) print body New user registration for user nueces -- Grupo de Relatividad y Gravitación <https://relatividad....> Relatividad y Gravitación (Pdb) self.subject u'[Grupo de Relatividad y Gravitaci\xf3n] New user registration: nueces' (Pdb)
In the trac documentation(1) is specific by default the mime_encoding should be base64, but here are using 'ascii'
(1) http://trac.edgewall.org/wiki/TracNotification#ConfigurationOptions
The send method was copied from trac/notification.py I think it could be removed. An patch is attached for that. I made the path for trunk but the same changes work for the TracAccountManager-0.2.1dev_r4679.
Changed 14 years ago by
Attachment: | notification-remove_send_method.patch added |
---|
remove the send method and use the inherit from the parent class.
Changed 14 years ago by
Attachment: | accountmanagerplugin-0.12-attribute.patch added |
---|
Updated patch for e.acct_mgr problem
comment:28 follow-up: 36 Changed 14 years ago by
Trac Release: | 0.11 → 0.12 |
---|
Hi!
Attached is the updated patch for the reported issue against latest SVN version. The typo has been indeed fixed in the trunk, but there are few other instances of direct calls to e.acct_mgr that were left behind. This patch fixes the issue completely.
Don't be misleaded by Havok. He was confused by the branches. In 0.11 it's indeed not fixed and it has to be fixed by applying typo patch AND kind of my patch, in 0.12 as of now it's fixed partially, that is the typo is fixed, but other instances of the call are not. That's what the updated patch is for.
Actually, I think all raises have to be tracked down and then my patch will be made unnecessary. Particularly in the set_password code, which currently exposes this bug for most.
Best,
--Yury @ RPMForge
comment:30 Changed 14 years ago by
Cc: | mcpbalaji@… added |
---|---|
Keywords: | unicode change notify added |
Owner: | changed from Matt Good to John Hampton |
Status: | reopened → new |
#7254 has been closed as another duplicate. However it suggests that account change notification and unicode issues may be part of the problem, since a workaround by removing Chinese chars from Trac project description was successfully tested there.
comment:31 Changed 14 years ago by
Replying to fermulator:
SOLVED: Giving read/write to the parent (containing) directory of the htdigest.user-auth file (in my case /usr/local/trac/user-auth.htaccess), eliminated this error!
This worked for me too.
comment:32 Changed 14 years ago by
Keywords: | needinfo added |
---|---|
Priority: | high → normal |
I can't reproduce with current trunk version neither the unicode-related issue(s) nor the file/directory access related ones (returns IOError: [Errno 30] Read-only file system: '/data/trac/sandbox/.htpasswd'
now).
As this has been reported against the PasswordFileStores, at least whenever a AuthStore was explicitly mentioned, this should be mostly, if not solely due to changes in [9272].
Anyway, this is not an easy one. I'll only step down priority for now and still wait for more feedback, before finally closing this ticket after a while.
comment:33 Changed 14 years ago by
Owner: | changed from John Hampton to Steffen Hoffmann |
---|
comment:34 Changed 14 years ago by
(In [9321]) AccountManagerPlugin: Remove obsolete method, refs #4040 and #6803.
send
method could be removed and the one inherited from the parent
class used instead. Thanks to nueces for suggesting this code cleanup.
While initially adding markup for i18n support in changeset [9318] I missed some recently added strings. This is corrected now and catalogs are updated as well.
comment:35 Changed 14 years ago by
Keywords: | needinfo removed |
---|---|
Status: | new → assigned |
Summary: | TracError instance has no attribute 'acctmgr' on new user creation → [patch] TracError instance has no attribute 'acctmgr' on new user creation |
I could finally reproduce this issue on my test system. Hopefully this will enable me to finally fix it.
comment:36 Changed 14 years ago by
Replying to anonymous:
![...] Don't be misleaded by Havok. He was confused by the branches. In 0.11 it's indeed not fixed and it has to be fixed by applying typo patch AND kind of my patch, in 0.12 as of now it's fixed partially, that is the typo is fixed, but other instances of the call are not. That's what the updated patch is for.
Actually, I think all raises have to be tracked down and then my patch will be made unnecessary. Particularly in the set_password code, which currently exposes this bug for most.
True, better have a valid acctmgr attribute everywhere. OTOH this could be even plugins extending AccountManagerPlugin, that are out of (our/my) control. So a fix just filling the gap would be preferred over raising the reported error.
Fixing this for my (test) case with a read-only .htpasswd file actually enabled the web UI to present the proper error message generated by htfile.py
. So I feel good with the latest patch.
comment:37 Changed 14 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
(In [9347]) AccountManagerPlugin: Improve error handling when writing to password files, closes #4040 and #5247, refs #6803.
Some messages without i18n markup were found while examining the code, so corresponding additions and updates to message catalogs are included as well.
Turns out the problem was I was using htdigest for the AccountManager to do authentication. And it seems that I need to add the username to the htdigest file before I can edit the new user. Not sure if I am missing any setup steps.
-Aaron