Site and email settings
Stefan Bund [Sat, 24 Oct 2009 13:47:19 +0000 (15:47 +0200)]
src/koehsel.policy/koehsel/policy/profiles/default/mailhost.xml [new file with mode: 0644]
src/koehsel.policy/koehsel/policy/profiles/default/properties.xml [new file with mode: 0644]
src/koehsel.policy/koehsel/policy/setuphandlers.py

diff --git a/src/koehsel.policy/koehsel/policy/profiles/default/mailhost.xml b/src/koehsel.policy/koehsel/policy/profiles/default/mailhost.xml
new file mode 100644 (file)
index 0000000..158e123
--- /dev/null
@@ -0,0 +1,3 @@
+<?xml version="1.0"?>
+<object name="MailHost" meta_type="Secure Mail Host" smtp_host="localhost"
+   smtp_port="25" smtp_pwd="" smtp_uid=""/>
diff --git a/src/koehsel.policy/koehsel/policy/profiles/default/properties.xml b/src/koehsel.policy/koehsel/policy/profiles/default/properties.xml
new file mode 100644 (file)
index 0000000..b877054
--- /dev/null
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<site>
+ <property name="title">Köhsel &amp; Sohn</property>
+ <property name="description"></property>
+ <property name="default_page" type="string">front-page</property>
+ <property name="selectable_views" type="lines">
+  <element value="folder_listing"/>
+  <element value="news_listing"/>
+ </property>
+ <property name="email_from_address" type="string">webmaster@localhost</property>
+ <property name="email_from_name" type="string">Site Administrator</property>
+ <property name="validate_email" type="boolean">True</property>
+ <property name="email_charset" type="string">utf-8</property>
+ <property name="enable_permalink" type="boolean">False</property>
+</site>
index e99f39b..c37da6a 100644 (file)
@@ -10,47 +10,13 @@ INSTALL_PRODUCTS = [
 ]
 
 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')    
 
@@ -86,23 +52,61 @@ def siteSetupContent(site):
     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)