Clean up skeleton and remove easyshop stuff into extra branch
[zope-bootstrap.git] / src / koehsel.policy / koehsel / policy / setuphandlers.py
diff --git a/src/koehsel.policy/koehsel/policy/setuphandlers.py b/src/koehsel.policy/koehsel/policy/setuphandlers.py
deleted file mode 100644 (file)
index c8576f4..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-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', 
-    'koehsel.theme',
-]
-
-SITE_OWNER = 'admin'
-SITE_NAME = 'site'
-
-def siteSetupContent(site):
-
-    try: site.shop
-    except AttributeError: pass
-    else: return
-
-    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
-
-    for id in ('Members', 'news', 'events'):
-        ob = getattr(site,id)
-        if wf.getInfoFor(ob,'review_state','') != 'private':
-            wf.doActionFor(ob,'retract',comment='site setup')
-
-    # Add sample user
-    
-    mt = getToolByName(site,'portal_membership')
-    mt.addMember(id='shop', password='shop', roles=('Member',), domains=())
-    member = mt.getMemberById('shop')
-    member.setMemberProperties({'fullname': 'Shop Testuser'},
-                               {'email': 'test@localhost'})
-
-
-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()
-
-    # Install products
-
-    qi = getToolByName(site, 'portal_quickinstaller')
-    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_NAME,
-                                                   extension_ids=['koehsel.policy:default'])
-
-
-# Called via hackery in __init__.py on every site start
-def appInit(app):
-    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)