misc/migration/postcreate.py
branch3.5
changeset 2920 64322aa83a1d
parent 2172 cf8f9180e63e
child 3005 a50d03e7014f
--- a/misc/migration/postcreate.py	Thu Aug 20 17:33:05 2009 +0200
+++ b/misc/migration/postcreate.py	Thu Aug 20 17:44:27 2009 +0200
@@ -15,17 +15,19 @@
                (deactivatedeid,), activatedeid,
                requiredgroups=('managers',))
 
-# need this since we already have at least one user in the database (the default admin)
-rql('SET X in_state S WHERE X is CWUser, S eid %s' % activatedeid)
-
 # create anonymous user if all-in-one config and anonymous user has been specified
 if hasattr(config, 'anonymous_user'):
     anonlogin, anonpwd = config.anonymous_user()
     if anonlogin:
         rql('INSERT CWUser X: X login %(login)s, X upassword %(pwd)s,'
-            'X in_state S, X in_group G WHERE G name "guests", S name "activated"',
+            'X in_group G WHERE G name "guests"',
             {'login': unicode(anonlogin), 'pwd': anonpwd})
 
+# need this since we already have at least one user in the database (the default admin)
+for user in rql('Any X WHERE X is CWUser').entities():
+    session.unsafe_execute('SET X in_state S WHERE X eid %(x)s, S eid %(s)s',
+                           {'x': user.eid, 's': activatedeid}, 'x')
+
 cfg = config.persistent_options_configuration()
 if interactive_mode:
     cfg.input_config(inputlevel=0)