-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']
- if context.readDataFile('koehsel.theme_various.txt') is None:
+def siteSetup(context):
+
+ if context.readDataFile('koehsel.policy_setup.txt') is None:
return
- # Add additional setup code here
+ site = context.getSite()
+
+ # Install EasyShop product
+
+ qi = getToolByName(site, 'portal_quickinstaller')
+ 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'
+ wf = getToolByName(site, 'portal_workflow')
+ 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')
+
+
+# Called via hackery in __init__.py
+def appInit(app):
+ try: app.site
+ except AttributeError:
+ app.manage_addProduct['CMFPlone'].addPloneSite(id='site',
+ extension_ids=['koehsel.policy:default'])