[Zope-Checkins] SVN: Zope/trunk/src/OFS/ Added automatic inline migration for the root user folder

Hanno Schlichting hannosch at hannosch.eu
Sat Jun 19 11:47:20 EDT 2010


Log message for revision 113652:
  Added automatic inline migration for the root user folder
  

Changed:
  U   Zope/trunk/src/OFS/Application.py
  U   Zope/trunk/src/OFS/userfolder.py

-=-
Modified: Zope/trunk/src/OFS/Application.py
===================================================================
--- Zope/trunk/src/OFS/Application.py	2010-06-19 15:16:30 UTC (rev 113651)
+++ Zope/trunk/src/OFS/Application.py	2010-06-19 15:47:20 UTC (rev 113652)
@@ -445,13 +445,27 @@
 
     def install_inituser(self):
         app = self.getApp()
-
         # Install the initial user.
         if hasattr(app, 'acl_users'):
             users = app.acl_users
             if hasattr(users, '_createInitialUser'):
                 app.acl_users._createInitialUser()
                 self.commit('Created initial user')
+            users = aq_base(users)
+            migrated = getattr(users, '_ofs_migrated', False)
+            if not migrated:
+                klass = users.__class__
+                from OFS.userfolder import UserFolder
+                if klass is UserFolder:
+                    # zope.deferredimport does a thourough job, so the class
+                    # looks like it's from the new location already. And we
+                    # don't want to migrate any custom user folders here.
+                    users.__class__ = UserFolder
+                    users._ofs_migrated = True
+                    users._p_changed = True
+                    app._p_changed = True
+                    transaction.get().note('Migrated user folder')
+                    transaction.commit()
 
     def install_errorlog(self):
         app = self.getApp()

Modified: Zope/trunk/src/OFS/userfolder.py
===================================================================
--- Zope/trunk/src/OFS/userfolder.py	2010-06-19 15:16:30 UTC (rev 113651)
+++ Zope/trunk/src/OFS/userfolder.py	2010-06-19 15:47:20 UTC (rev 113652)
@@ -303,7 +303,12 @@
     users and binding them to a collection of roles."""
 
     icon = 'p_/UserFolder'
+    _ofs_migrated = False
 
+    def __init__(self):
+        super(UserFolder, self).__init__()
+        self._ofs_migrated = True
+
     def _createInitialUser(self):
         """
         If there are no users or only one user in this user folder,



More information about the Zope-Checkins mailing list