From: Stefan Bund Date: Wed, 21 Oct 2009 09:24:45 +0000 (+0200) Subject: Auto-create initial PloneSite instance on zope startup X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=3fc2781f2f1915090402c0a8db560385a4d7f43a;p=zope-bootstrap.git Auto-create initial PloneSite instance on zope startup --- diff --git a/.gitignore b/.gitignore index 7513caf..cfb4c87 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ parts/ *.pyc easyshop/ /local.cfg +SOURCES.txt diff --git a/Makefile.master b/Makefile.master index 19e6634..6d9a7f6 100644 --- a/Makefile.master +++ b/Makefile.master @@ -80,7 +80,7 @@ bootstrap: shell: @PATH=$(BASEDIR)/$(PYTHON_DIR)/bin:$(BASEDIR)/bin:$$PATH $$SHELL -init: python setuptools pil eggs buildout bootstrap otherinit update .gitignore +init: python setuptools pil eggs buildout otherinit otherupdate bootstrap update .gitignore otherinit:: diff --git a/src/koehsel.policy/koehsel.policy.egg-info/SOURCES.txt b/src/koehsel.policy/koehsel.policy.egg-info/SOURCES.txt deleted file mode 100644 index 06f823e..0000000 --- a/src/koehsel.policy/koehsel.policy.egg-info/SOURCES.txt +++ /dev/null @@ -1,16 +0,0 @@ -README.txt -setup.cfg -setup.py -koehsel/__init__.py -koehsel.policy.egg-info/PKG-INFO -koehsel.policy.egg-info/SOURCES.txt -koehsel.policy.egg-info/dependency_links.txt -koehsel.policy.egg-info/entry_points.txt -koehsel.policy.egg-info/namespace_packages.txt -koehsel.policy.egg-info/not-zip-safe -koehsel.policy.egg-info/paster_plugins.txt -koehsel.policy.egg-info/requires.txt -koehsel.policy.egg-info/top_level.txt -koehsel/policy/__init__.py -koehsel/policy/setuphandlers.py -koehsel/policy/tests.py \ No newline at end of file diff --git a/src/koehsel.policy/koehsel/policy/__init__.py b/src/koehsel.policy/koehsel/policy/__init__.py index 52f45a0..b5e70dc 100644 --- a/src/koehsel.policy/koehsel/policy/__init__.py +++ b/src/koehsel.policy/koehsel/policy/__init__.py @@ -1,3 +1,30 @@ +import setuphandlers +import OFS.Application +from App.Product import doInstall +import transaction +from AccessControl.SecurityManagement import newSecurityManager +import AccessControl +from Testing.makerequest import makerequest + +orig_install_standards = None + +def install_standards(app): + orig_install_standards(app) + transaction.commit() + + # Log in as 'admin' user + newSecurityManager(None, app.acl_users.getUser('admin')) + setuphandlers.appInit(makerequest(app)) + transaction.commit() + + # Back to system user + newSecurityManager(None, AccessControl.User.system) + def initialize(context): """Initializer called when used as a Zope 2 product.""" + global orig_install_standards + + if doInstall(): + orig_install_standards = OFS.Application.install_standards + OFS.Application.install_standards = install_standards diff --git a/src/koehsel.policy/koehsel/policy/configure.zcml b/src/koehsel.policy/koehsel/policy/configure.zcml index 56160c0..ab82b3b 100644 --- a/src/koehsel.policy/koehsel/policy/configure.zcml +++ b/src/koehsel.policy/koehsel/policy/configure.zcml @@ -5,20 +5,6 @@ i18n_domain="koehsel.policy"> - - - - - + diff --git a/src/koehsel.policy/koehsel/policy/profiles.zcml b/src/koehsel.policy/koehsel/policy/profiles.zcml new file mode 100644 index 0000000..86474da --- /dev/null +++ b/src/koehsel.policy/koehsel/policy/profiles.zcml @@ -0,0 +1,22 @@ + + + + + + + + + diff --git a/src/koehsel.policy/koehsel/policy/profiles/default/koehsel.policy_setup.txt b/src/koehsel.policy/koehsel/policy/profiles/default/koehsel.policy_setup.txt new file mode 100644 index 0000000..3e135d9 --- /dev/null +++ b/src/koehsel.policy/koehsel/policy/profiles/default/koehsel.policy_setup.txt @@ -0,0 +1 @@ +Marker file diff --git a/src/koehsel.policy/koehsel/policy/profiles/default/metadata.xml b/src/koehsel.policy/koehsel/policy/profiles/default/metadata.xml index ade50ca..5273b2c 100644 --- a/src/koehsel.policy/koehsel/policy/profiles/default/metadata.xml +++ b/src/koehsel.policy/koehsel/policy/profiles/default/metadata.xml @@ -2,7 +2,6 @@ 1 - profile-easyshop.core:default profile-koehsel.theme:default diff --git a/src/koehsel.policy/koehsel/policy/setuphandlers.py b/src/koehsel.policy/koehsel/policy/setuphandlers.py index 5140789..22b3a87 100644 --- a/src/koehsel.policy/koehsel/policy/setuphandlers.py +++ b/src/koehsel.policy/koehsel/policy/setuphandlers.py @@ -1,11 +1,44 @@ -def setupVarious(context): +from Products.CMFCore.utils import getToolByName - # Ordinarily, GenericSetup handlers check for the existence of XML files. - # Here, we are not parsing an XML file, but we use this text file as a - # flag to check that we actually meant for this import step to be run. - # The file is found in profiles/default. +INSTALL_PRODUCTS = ['easyshop.core'] - if context.readDataFile('koehsel.theme_various.txt') is None: +def siteSetup(context): + + if context.readDataFile('koehsel.policy_setup.txt') is None: return - # Add additional setup code here + site = context.getSite() + + # Install EasyShop product + + qi = getToolByName(site, 'portal_quickinstaller') + for p in INSTALL_PRODUCTS: + if not qi.isProductInstalled(p): + qi.installProduct(p) + + # Add and publish shop instance + + try: site.shop + except AttributeError: + site.invokeFactory(id='shop', type_name='EasyShop') + shop = site.shop + shop.title = 'Shop' + shop.shopOwner = 'admin' + wf = getToolByName(site, 'portal_workflow') + 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') + + +# Called via hackery in __init__.py +def appInit(app): + try: app.site + except AttributeError: + app.manage_addProduct['CMFPlone'].addPloneSite(id='site', + extension_ids=['koehsel.policy:default']) diff --git a/src/koehsel.theme/koehsel.theme.egg-info/SOURCES.txt b/src/koehsel.theme/koehsel.theme.egg-info/SOURCES.txt deleted file mode 100644 index 9e5a4e1..0000000 --- a/src/koehsel.theme/koehsel.theme.egg-info/SOURCES.txt +++ /dev/null @@ -1,42 +0,0 @@ -MANIFEST.in -README.txt -setup.cfg -setup.py -koehsel/__init__.py -koehsel.theme.egg-info/PKG-INFO -koehsel.theme.egg-info/SOURCES.txt -koehsel.theme.egg-info/dependency_links.txt -koehsel.theme.egg-info/entry_points.txt -koehsel.theme.egg-info/namespace_packages.txt -koehsel.theme.egg-info/not-zip-safe -koehsel.theme.egg-info/paster_plugins.txt -koehsel.theme.egg-info/requires.txt -koehsel.theme.egg-info/top_level.txt -koehsel/theme/__init__.py -koehsel/theme/configure.zcml -koehsel/theme/profiles.zcml -koehsel/theme/setuphandlers.py -koehsel/theme/skins.zcml -koehsel/theme/tests.py -koehsel/theme/version.txt -koehsel/theme/browser/__init__.py -koehsel/theme/browser/configure.zcml -koehsel/theme/browser/interfaces.py -koehsel/theme/browser/viewlet.pt -koehsel/theme/browser/viewlets.py -koehsel/theme/browser/images/README.txt -koehsel/theme/browser/stylesheets/README.txt -koehsel/theme/browser/stylesheets/main.css -koehsel/theme/profiles/default/cssregistry.xml -koehsel/theme/profiles/default/jsregistry.xml -koehsel/theme/profiles/default/koehsel.theme_various.txt -koehsel/theme/profiles/default/metadata.xml -koehsel/theme/profiles/default/portlets.xml -koehsel/theme/profiles/default/portlets.xml~ -koehsel/theme/profiles/default/skins.xml -koehsel/theme/profiles/default/viewlets.xml -koehsel/theme/skins/koehsel_theme_custom_images/CONTENT.txt -koehsel/theme/skins/koehsel_theme_custom_images/logo.jpg -koehsel/theme/skins/koehsel_theme_custom_templates/CONTENT.txt -koehsel/theme/skins/koehsel_theme_styles/CONTENT.txt -koehsel/theme/skins/koehsel_theme_styles/base_properties.props \ No newline at end of file