Fix extension installation ordering (fixes layer order)
Stefan Bund [Wed, 21 Oct 2009 13:23:04 +0000 (15:23 +0200)]
Makefile
src/koehsel.policy/koehsel/policy/__init__.py
src/koehsel.policy/koehsel/policy/profiles/default/metadata.xml
src/koehsel.policy/koehsel/policy/setuphandlers.py

index 31446b9..66bf7c1 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -22,5 +22,17 @@ local.cfg:
                echo "    \$${local:eggs}"                                      \
        ) >$@ || (rm -f $@; false)
 .PHONY: local.cfg
+# Not phony in reality but needs to be considered out-of-date whenever called
 
 otherupdate:: local.cfg
+
+instance: update-nonet
+       bin/instance foreground
+.PHONY: instance
+
+newinstance: purgeinstance instance
+.PHONY: newinstance
+
+purgeinstance:
+       rm -rf parts/instance var/filestorage
+.PHONY: purgeinstance
index b5e70dc..885066c 100644 (file)
@@ -2,24 +2,12 @@ import setuphandlers
 import OFS.Application
 from App.Product import doInstall
 import transaction
-from AccessControl.SecurityManagement import newSecurityManager
-import AccessControl
-from Testing.makerequest import makerequest
 
 orig_install_standards = None
 
 def install_standards(app):
     orig_install_standards(app)
-    transaction.commit()
-
-    # Log in as 'admin' user
-    newSecurityManager(None, app.acl_users.getUser('admin'))
-    setuphandlers.appInit(makerequest(app))
-    transaction.commit()
-
-    # Back to system user
-    newSecurityManager(None, AccessControl.User.system)
-
+    setuphandlers.appInit(app)
 
 def initialize(context):
     """Initializer called when used as a Zope 2 product."""
index 5273b2c..cf4492a 100644 (file)
@@ -1,7 +1,4 @@
 <?xml version="1.0"?>
 <metadata>
   <version>1</version>
-  <dependencies>
-    <dependency>profile-koehsel.theme:default</dependency>
-  </dependencies>
 </metadata>
index 22b3a87..dc45961 100644 (file)
@@ -1,6 +1,11 @@
 from Products.CMFCore.utils import getToolByName
 
-INSTALL_PRODUCTS = ['easyshop.core']
+INSTALL_PRODUCTS = [
+    'easyshop.core', 
+    'koehsel.theme',
+]
+
+SITE_OWNER = 'admin'
 
 def siteSetup(context):
 
@@ -8,10 +13,11 @@ def siteSetup(context):
         return
 
     site = context.getSite()
+    qi = getToolByName(site, 'portal_quickinstaller')
+    wf = getToolByName(site, 'portal_workflow')    
 
     # Install EasyShop product
 
-    qi = getToolByName(site, 'portal_quickinstaller')
     for p in INSTALL_PRODUCTS:
         if not qi.isProductInstalled(p):
             qi.installProduct(p)
@@ -24,7 +30,6 @@ def siteSetup(context):
         shop = site.shop
         shop.title = 'Shop'
         shop.shopOwner = 'admin'
-        wf = getToolByName(site, 'portal_workflow')    
         if wf.getInfoFor(shop,'review_state','') != 'published':
             wf.doActionFor(shop,'publish',comment='site setup')
 
@@ -36,9 +41,23 @@ def siteSetup(context):
             wf.doActionFor(ob,'retract',comment='site setup')
 
 
-# Called via hackery in __init__.py
+def contentSetup(app):
+    app.manage_addProduct['CMFPlone'].addPloneSite(id='site',
+                                                   extension_ids=['koehsel.policy:default'])
+
+
+# Called via hackery in __init__.py on every site start
 def appInit(app):
     try: app.site
     except AttributeError:
-        app.manage_addProduct['CMFPlone'].addPloneSite(id='site',
-                                                       extension_ids=['koehsel.policy:default'])
+
+        from Testing.makerequest import makerequest
+        from AccessControl.SecurityManagement import newSecurityManager
+        import transaction, AccessControl
+
+        # Call 'contentSetup' as SITE_OWNER user with a valid REQUEST
+        req = makerequest(app)
+        newSecurityManager(req.REQUEST, app.acl_users.getUser(SITE_OWNER).__of__(app.acl_users))
+        contentSetup(req)
+        transaction.commit()
+        newSecurityManager(None, AccessControl.User.system)