X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=src%2Fkoehsel.policy%2Fkoehsel%2Fpolicy%2Fsetuphandlers.py;h=dc4596116b331d34ff3aa0e89ff8723f11ad98e8;hb=d98e4b951d121fff66448024b8a54d43a2506a2f;hp=51407890b0e4475ff9293a6b6374ed3a5b44874b;hpb=f53789c630416150b13df1204b0bb94334d7a0b0;p=zope-bootstrap.git diff --git a/src/koehsel.policy/koehsel/policy/setuphandlers.py b/src/koehsel.policy/koehsel/policy/setuphandlers.py index 5140789..dc45961 100644 --- a/src/koehsel.policy/koehsel/policy/setuphandlers.py +++ b/src/koehsel.policy/koehsel/policy/setuphandlers.py @@ -1,11 +1,63 @@ -def setupVarious(context): +from Products.CMFCore.utils import getToolByName - # Ordinarily, GenericSetup handlers check for the existence of XML files. - # Here, we are not parsing an XML file, but we use this text file as a - # flag to check that we actually meant for this import step to be run. - # The file is found in profiles/default. +INSTALL_PRODUCTS = [ + 'easyshop.core', + 'koehsel.theme', +] - if context.readDataFile('koehsel.theme_various.txt') is None: +SITE_OWNER = 'admin' + +def siteSetup(context): + + if context.readDataFile('koehsel.policy_setup.txt') is None: return - # Add additional setup code here + site = context.getSite() + qi = getToolByName(site, 'portal_quickinstaller') + wf = getToolByName(site, 'portal_workflow') + + # Install EasyShop product + + for p in INSTALL_PRODUCTS: + if not qi.isProductInstalled(p): + qi.installProduct(p) + + # Add and publish shop instance + + try: site.shop + except AttributeError: + site.invokeFactory(id='shop', type_name='EasyShop') + shop = site.shop + shop.title = 'Shop' + shop.shopOwner = 'admin' + if wf.getInfoFor(shop,'review_state','') != 'published': + wf.doActionFor(shop,'publish',comment='site setup') + + # Hide Users, News and Events + + for id in ('Members', 'news', 'events'): + ob = getattr(site,id) + if wf.getInfoFor(ob,'review_state','') != 'private': + wf.doActionFor(ob,'retract',comment='site setup') + + +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: + + 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)