From: Stefan Bund Date: Fri, 23 Oct 2009 10:05:30 +0000 (+0200) Subject: More initial site setup (user, security policy) X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=1e4a3a78ba63533129b39f9f774f0980d1d31b5b;p=zope-bootstrap.git More initial site setup (user, security policy) --- diff --git a/src/koehsel.policy/koehsel/policy/setuphandlers.py b/src/koehsel.policy/koehsel/policy/setuphandlers.py index d175a1f..e99f39b 100644 --- a/src/koehsel.policy/koehsel/policy/setuphandlers.py +++ b/src/koehsel.policy/koehsel/policy/setuphandlers.py @@ -2,6 +2,7 @@ from Products.CMFCore.utils import getToolByName from Acquisition import aq_base from zope import event from Products.Archetypes.event import ObjectInitializedEvent +from plone.app.controlpanel.security import SecurityControlPanelAdapter INSTALL_PRODUCTS = [ 'easyshop.core', @@ -10,7 +11,7 @@ INSTALL_PRODUCTS = [ SITE_OWNER = 'admin' -def makePublicObject(container, type_name, id, **kw): +def makeObject(container, type_name, id, **kw): """Create an object in CONTAINER with type TYPE_NAME and id ID. Additional keyword args specify additional factory arguments. After creation, the object is published if needed.""" id = container.invokeFactory(id=id, type_name=type_name, **kw) @@ -20,9 +21,7 @@ specify additional factory arguments. After creation, the object is published if ob.at_post_create_script() if hasattr(aq_base(ob), 'manage_afterPortalFactoryCreate'): ob.manage_afterPortalFactoryCreate() - wf = getToolByName(container, 'portal_workflow') - if wf.getInfoFor(ob,'review_state','') != 'published': - wf.doActionFor(ob,'publish',comment='site setup') + return ob def siteSetup(context): @@ -32,7 +31,6 @@ def siteSetup(context): site = context.getSite() qi = getToolByName(site, 'portal_quickinstaller') - wf = getToolByName(site, 'portal_workflow') # Install EasyShop product @@ -40,12 +38,38 @@ def siteSetup(context): if not qi.isProductInstalled(p): qi.installProduct(p) - # Add and publish shop instance + # Enable Self-Registration + + scpa = SecurityControlPanelAdapter(site) + scpa.set_enable_self_reg(True) + + # If not already installed, initialize development content try: site.shop except AttributeError: - makePublicObject(container=site, type_name='EasyShop', - id='shop', title='Shop', shopOwner='admin') + siteSetupContent(site) + + +def siteSetupContent(site): + + wf = getToolByName(site, 'portal_workflow') + + # Change front-page stuff + + fp = getattr(site,'front-page') + fp.setTitle("Startsteite") + fp.setDescription("") + fp.setText("") + fp.setPresentation(False) + fp.reindexObject() + + # Create easy-shop instance + + shop = makeObject(container=site, type_name='EasyShop', id='shop', + title='Shop', shopOwner='admin') + + if wf.getInfoFor(shop,'review_state','') != 'published': + wf.doActionFor(shop,'publish',comment='site setup') # Hide Users, News and Events @@ -54,6 +78,13 @@ def siteSetup(context): if wf.getInfoFor(ob,'review_state','') != 'private': wf.doActionFor(ob,'retract',comment='site setup') + # Add sample user + + mt = getToolByName(site,'portal_membership') + mt.addMember('shop','shop',[],[]) + member = mt.getMemberById('shop') + member.setMemberProperties({'fullname': 'Shop Testuser'}) + def contentSetup(app): app.manage_addProduct['CMFPlone'].addPloneSite(id='site',