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',
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)
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):
site = context.getSite()
qi = getToolByName(site, 'portal_quickinstaller')
- wf = getToolByName(site, 'portal_workflow')
# Install EasyShop product
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
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',