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 #635 (closed defect: duplicate)

Opened 13 years ago

Last modified 12 years ago

tg-admin shell doesn't make TG_User

Reported by: heikichi3@… Owned by: anonymous
Priority: normal Milestone:
Component: Identity Version:
Severity: normal Keywords:


I was going to make TG_User in tg-admin shell on 0.9a1, but was not able to make it.

 >>> from turbogears.identity.soprovider import *
 >>> u=TG_User( userId="jeff", emailAddress="jeff@metrocat.org",
...             displayName="Jeff Watkins", password="xxxxx" )
Traceback (most recent call last):
   File "<console>", line 2, in ?
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
main.py", line 1197, in __init__
     self._create(id, **kw)
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
inheritance/__init__.py", line 218, in _create
     super(InheritableSQLObject, self)._create(id, **kw)
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
main.py", line 1221, in _create
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
main.py", line 1097, in set
     setattr(self, name, value)
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
identity/soprovider.py", line 292, in _set_password
     hash = identity.current_provider.encrypt_password 
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
identity/__init__.py", line 74, in __getattr__
     raise IdentityManagementNotEnabledException()
IdentityManagementNotEnabledException: An attempt was made to use a  
facility of the TurboGears Identity Management framework but identity  
management hasn't been enabled in the config file [via identity.on].

Change History

comment:1 Changed 13 years ago by godoy

  • Priority changed from normal to low
  • Severity changed from normal to trivial

As explicited in the exception, you have to enable identity before you use it.

comment:2 Changed 13 years ago by heikichi3@…

I enabled identity before I used it.

I set next items in config.py.


A cause is because TG_User cannot acquire current_provider.

--- soprovider.py     (revision 815)
+++ soprovider.py     (working copy)
@@ -150,13 +150,7 @@
         permission_class= _load_class(permission_class_path)
         # Default encryption algorithm is to use plain text passwords
-        algorithm= get( "identity.soprovider.encryption_algorithm", None )
-        if "md5"==algorithm:
-            self.encrypt_password= lambda pw: md5.new(pw).hexdigest()
-        elif "sha1"==algorithm:
-            self.encrypt_password= lambda pw: sha.new(pw).hexdigest()
-        else:
-            self.encrypt_password= lambda pw: pw
+        self.encrypt_password = encrypt_password
     def create_provider_model( self ):
         # create the database tables
@@ -289,7 +283,7 @@
     def _set_password( self, cleartext_password ):
         "Runs cleartext_password through the hash algorithm before saving."
-        hash = identity.current_provider.encrypt_password(cleartext_password)
+        hash = encrypt_password(cleartext_password)
     def set_password_raw( self, password ):
@@ -323,4 +317,15 @@
     return result
 jsonify_permission = jsonify.when(
-        'isinstance(obj, TG_Permission)')(jsonify_permission)
\ No newline at end of file
+        'isinstance(obj, TG_Permission)')(jsonify_permission)
+def get_encrypt_password():
+    algorithm= cherrypy.config.get( "identity.soprovider.encryption_algorithm", None )
+    if "md5"==algorithm:
+        return lambda pw: md5.new(pw).hexdigest()
+    elif "sha1"==algorithm:
+        return lambda pw: sha.new(pw).hexdigest()
+    else:
+        return lambda pw: pw
+encrypt_password = get_encrypt_password()

comment:3 Changed 13 years ago by cliff@…

  • Priority changed from low to normal
  • Severity changed from trivial to normal

Same results here (exception) on a fresh project with TurboGears 0.9a1dev-r896

comment:4 Changed 13 years ago by plewis

There is a similar ticket (and patch) in issue #624

comment:5 Changed 13 years ago by kevin

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

This problem has been fixed by #624.

Note: See TracTickets for help on using tickets.