]
SITE_OWNER = 'admin'
+SITE_NAME = 'site'
-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 = getattr(container,id)
- event.notify(ObjectInitializedEvent(ob))
- if hasattr(aq_base(ob), 'at_post_create_script'):
- ob.at_post_create_script()
- if hasattr(aq_base(ob), 'manage_afterPortalFactoryCreate'):
- ob.manage_afterPortalFactoryCreate()
- return ob
-
-
-def siteSetup(context):
-
- if context.readDataFile('koehsel.policy_setup.txt') is None:
- return
-
- site = context.getSite()
- qi = getToolByName(site, 'portal_quickinstaller')
-
- # Install EasyShop product
-
- for p in INSTALL_PRODUCTS:
- if not qi.isProductInstalled(p):
- qi.installProduct(p)
-
- # Enable Self-Registration
-
- scpa = SecurityControlPanelAdapter(site)
- scpa.set_enable_self_reg(True)
-
- # If not already installed, initialize development content
+def siteSetupContent(site):
try: site.shop
- except AttributeError:
- siteSetupContent(site)
-
-
-def siteSetupContent(site):
+ except AttributeError: pass
+ else: return
wf = getToolByName(site, 'portal_workflow')
member.setMemberProperties({'fullname': 'Shop Testuser'})
+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 = getattr(container,id)
+ event.notify(ObjectInitializedEvent(ob))
+ if hasattr(aq_base(ob), 'at_post_create_script'):
+ ob.at_post_create_script()
+ if hasattr(aq_base(ob), 'manage_afterPortalFactoryCreate'):
+ ob.manage_afterPortalFactoryCreate()
+ return ob
+
+
+def siteSetup(context):
+
+ if context.readDataFile('koehsel.policy_setup.txt') is None:
+ return
+
+ site = context.getSite()
+ qi = getToolByName(site, 'portal_quickinstaller')
+
+ # Install EasyShop product
+
+ for p in INSTALL_PRODUCTS:
+ if not qi.isProductInstalled(p):
+ qi.installProduct(p)
+
+ # Enable Self-Registration
+
+ scpa = SecurityControlPanelAdapter(site)
+ scpa.set_enable_self_reg(True)
+
+ # If not already installed, initialize development content
+
+ siteSetupContent(site)
+
+
def contentSetup(app):
- app.manage_addProduct['CMFPlone'].addPloneSite(id='site',
+ app.manage_addProduct['CMFPlone'].addPloneSite(id=SITE_NAME,
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.getUserById(SITE_OWNER).__of__(app.acl_users))
- contentSetup(req)
- transaction.commit()
- newSecurityManager(None, AccessControl.User.system)
+ try: getattr(app,SITE_NAME)
+ except AttributeError: pass
+ else: return
+
+ 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.getUserById(SITE_OWNER).__of__(app.acl_users))
+ contentSetup(req)
+ transaction.commit()
+ newSecurityManager(None, AccessControl.User.system)