products/CpsDemoPortal

changeset 0:ca2d7838c01c

First import
author M.-A. Darche <ma.darche@aful.org>
date Sun, 12 Dec 2010 20:41:12 +0000
parents
children 94ca912fb3aa
files .hgignore Makefile __init__.py factory.py profiles/default/properties.xml
diffstat 5 files changed, 166 insertions(+), 0 deletions(-) [+]
line diff
     1.1 new file mode 100644
     1.2 --- /dev/null
     1.3 +++ b/.hgignore
     1.4 @@ -0,0 +1,15 @@
     1.5 +syntax: glob
     1.6 +*.class
     1.7 +*.pyc
     1.8 +*.orig
     1.9 +*.rej
    1.10 +*~
    1.11 +*.o
    1.12 +build/*
    1.13 +dist/*
    1.14 +tests/*.err
    1.15 +
    1.16 +syntax: regexp
    1.17 +.*\#.*\#$
    1.18 +
    1.19 +
     2.1 new file mode 100644
     2.2 --- /dev/null
     2.3 +++ b/Makefile
     2.4 @@ -0,0 +1,5 @@
     2.5 +.PHONY: clean
     2.6 +
     2.7 +clean:
     2.8 +	find . "(" -name "*~" -or  -name ".#*" -or -name "*.pyc" ")" -print0 | xargs -0 rm -f
     2.9 +
     3.1 new file mode 100644
     3.2 --- /dev/null
     3.3 +++ b/__init__.py
     3.4 @@ -0,0 +1,51 @@
     3.5 +# (C) Copyright 2010 CPS-CMS community <http://cps-cms.org/>
     3.6 +# Authors:
     3.7 +# M.-A. Darche <cps@cynode.org>
     3.8 +#
     3.9 +# This program is free software: you can redistribute it and/or modify
    3.10 +# it under the terms of the GNU General Public License as published by
    3.11 +# the Free Software Foundation, either version 2 of the License, or
    3.12 +# (at your option) any later version.
    3.13 +#
    3.14 +# This program is distributed in the hope that it will be useful,
    3.15 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
    3.16 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    3.17 +# GNU General Public License for more details.
    3.18 +#
    3.19 +# You should have received a copy of the GNU General Public License
    3.20 +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
    3.21 +""" Init """
    3.22 +
    3.23 +from Products.CMFCore.DirectoryView import registerDirectory
    3.24 +
    3.25 +from Products.GenericSetup import profile_registry
    3.26 +from Products.GenericSetup import EXTENSION
    3.27 +
    3.28 +from Products.CPSDefault.Portal import CPSDefaultSite
    3.29 +
    3.30 +from Products.CPSCore.interfaces import ICPSSite
    3.31 +
    3.32 +registerDirectory('skins', globals())
    3.33 +
    3.34 +import factory
    3.35 +
    3.36 +class CpsDemoPortal(CPSDefaultSite):
    3.37 +    """ Just a marker.
    3.38 +
    3.39 +    I'd rather add constructors to CPSDefault. Don't know if it'd work"""
    3.40 +    meta_type = 'CPS Demo Portal'
    3.41 +
    3.42 +def initialize(registrar):
    3.43 +    profile_registry.registerProfile(
    3.44 +        'default',
    3.45 +        "cps-cms.org look and feel",
    3.46 +        "CPS demo portal extension profile",
    3.47 +        'profiles/default',
    3.48 +        'CpsDemoPortal',
    3.49 +        EXTENSION,
    3.50 +        for_=ICPSSite)
    3.51 +
    3.52 +    registrar.registerClass(CpsDemoPortal,
    3.53 +                            constructors=(factory.addConfiguredCpsDemoPortalForm,
    3.54 +                                          factory.addConfiguredCpsDemoPortal))
    3.55 +
     4.1 new file mode 100644
     4.2 --- /dev/null
     4.3 +++ b/factory.py
     4.4 @@ -0,0 +1,70 @@
     4.5 +# (C) Copyright 2010 CPS-CMS community <http://cps-cms.org/>
     4.6 +# Authors:
     4.7 +# M.-A. Darche <cps@cynode.org>
     4.8 +#
     4.9 +# This program is free software: you can redistribute it and/or modify
    4.10 +# it under the terms of the GNU General Public License as published by
    4.11 +# the Free Software Foundation, either version 2 of the License, or
    4.12 +# (at your option) any later version.
    4.13 +#
    4.14 +# This program is distributed in the hope that it will be useful,
    4.15 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
    4.16 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    4.17 +# GNU General Public License for more details.
    4.18 +#
    4.19 +# You should have received a copy of the GNU General Public License
    4.20 +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
    4.21 +"""CPS demo portal factory."""
    4.22 +
    4.23 +from Products.CPSDefault.metafactory import CPSSiteMetaConfigurator
    4.24 +
    4.25 +#
    4.26 +# Callables for meta profiles
    4.27 +#
    4.28 +
    4.29 +def removeCookieCrumbler(site):
    4.30 +    site.manage_delObjects(['cookie_authentication'])
    4.31 +
    4.32 +class SiteConfigurator(CPSSiteMetaConfigurator):
    4.33 +     """CPS demo portal configurator"""
    4.34 +
    4.35 +     meta_profiles = {
    4.36 +         'CPS_DEMO': {'title' : 'Common set of components',
    4.37 +                             'extensions': ('CPSRSS:default',
    4.38 +                                            'CPSSubscriptions:default',
    4.39 +                                            'CPSDefault:folder_advanced_display',
    4.40 +                                            'CpsDemoPortal:default',
    4.41 +                                            ),
    4.42 +                          'optional' : False,
    4.43 +                          'parameters' : {'attributes': ('smtp_host',
    4.44 +                                                         'smtp_port',
    4.45 +                                                         'smtp_pwd',
    4.46 +                                                         'smtp_uid'),
    4.47 +                                          'class': 'Products.MailHost.'
    4.48 +                                                   'MailHost.MailHost',
    4.49 +                                          'rpath' : 'MailHost'},
    4.50 +                          }
    4.51 +         }
    4.52 +     metas_order = ('CPS_COMMUNITY',
    4.53 +                    )
    4.54 +     form_heading = "Add CPS demo portal"
    4.55 +     post_action = 'addConfiguredCpsDemoPortal'
    4.56 +
    4.57 +_cpsconfigurator = SiteConfigurator()
    4.58 +
    4.59 +# GR: straight from CPSDefault.factory
    4.60 +# Do the following dance because bound methods don't play well with
    4.61 +# constructors registered for products.
    4.62 +
    4.63 +def addConfiguredCpsDemoPortalForm(dispatcher):
    4.64 +    """Form to add a CPS Site from ZMI.
    4.65 +    """
    4.66 +    return _cpsconfigurator.addConfiguredSiteForm(dispatcher)
    4.67 +
    4.68 +def addConfiguredCpsDemoPortal(dispatcher, REQUEST=None, **kw):
    4.69 +    """Add a CPSSite according to profile and extensions.
    4.70 +    """
    4.71 +    if REQUEST is not None:
    4.72 +        kw.update(REQUEST.form)
    4.73 +    return _cpsconfigurator.addConfiguredSite(dispatcher,
    4.74 +                                              REQUEST=REQUEST, **kw)
     5.1 new file mode 100644
     5.2 --- /dev/null
     5.3 +++ b/profiles/default/properties.xml
     5.4 @@ -0,0 +1,25 @@
     5.5 +<?xml version="1.0"?>
     5.6 +<site>
     5.7 + <property name="title">CPS demo</property>
     5.8 + <property name="description">Free software / Libre / Open source demonstration portal</property>
     5.9 +
    5.10 + <property name="email_from_address">webmaster@cps-cms.org</property>
    5.11 + <property name="email_from_name">CPS demo webmasters</property>
    5.12 +
    5.13 + <!--
    5.14 + First language in the available_languages is the portal default language.
    5.15 +
    5.16 + For this setting to be used, one has to put a localizer.xml file, with just
    5.17 + the Localizer definition but no other definition, in the profile directory for
    5.18 + the Localizer importer to be started.
    5.19 + TODO: Suppress this constraint
    5.20 + -->
    5.21 + <property name="available_languages">en fr es</property>
    5.22 +
    5.23 + <property name=".cps_themes_bindings" type="lines">
    5.24 +  <element value="index_html:0-0:default+Front"/>
    5.25 + </property>
    5.26 +
    5.27 +</site>
    5.28 +
    5.29 +