[CMF-checkins] SVN: CMF/trunk/CMF - we now register a real class,
so we don't need all those tricks for 'factory only' registration
Yvo Schubbe
y.2005- at wcm-solutions.de
Sun Aug 7 13:01:42 EDT 2005
Log message for revision 37773:
- we now register a real class, so we don't need all those tricks for 'factory only' registration
- re-added manage_addCMFSite registration for backwards compatibility
- removed manage_addCMFSiteForm and the related addPortal.dtml completely
- moved factory.py and siteAddForm.zpt to CMFDefault
Changed:
U CMF/trunk/CMFDefault/Portal.py
U CMF/trunk/CMFDefault/__init__.py
D CMF/trunk/CMFDefault/dtml/addPortal.dtml
A CMF/trunk/CMFDefault/factory.py
U CMF/trunk/CMFDefault/tests/test_Portal.py
U CMF/trunk/CMFDefault/utils.py
A CMF/trunk/CMFDefault/www/
A CMF/trunk/CMFDefault/www/siteAddForm.zpt
D CMF/trunk/CMFSetup/factory.py
D CMF/trunk/CMFSetup/www/siteAddForm.zpt
-=-
Modified: CMF/trunk/CMFDefault/Portal.py
===================================================================
--- CMF/trunk/CMFDefault/Portal.py 2005-08-07 16:00:41 UTC (rev 37772)
+++ CMF/trunk/CMFDefault/Portal.py 2005-08-07 17:01:41 UTC (rev 37773)
@@ -284,9 +284,6 @@
p.description = description
-manage_addCMFSiteForm = HTMLFile('dtml/addPortal', globals())
-manage_addCMFSiteForm.__name__ = 'addPortal'
-
def manage_addCMFSite(self, id, title='Portal', description='',
create_userfolder=1,
email_from_address='postmaster at localhost',
Modified: CMF/trunk/CMFDefault/__init__.py
===================================================================
--- CMF/trunk/CMFDefault/__init__.py 2005-08-07 16:00:41 UTC (rev 37772)
+++ CMF/trunk/CMFDefault/__init__.py 2005-08-07 17:01:41 UTC (rev 37773)
@@ -24,6 +24,7 @@
from Products.CMFSetup import BASE
from Products.CMFSetup import profile_registry
+import factory
import utils
from permissions import AddPortalContent
@@ -115,24 +116,13 @@
'CMFDefault',
BASE)
- from Products.CMFSetup.factory import addConfiguredSiteForm
- from Products.CMFSetup.factory import addConfiguredSite
+ context.registerClass( Portal.CMFSite
+ , constructors=(factory.addConfiguredSiteForm,
+ factory.addConfiguredSite,
+ Portal.manage_addCMFSite)
+ , icon='images/portal.gif'
+ )
- # Add factory for a site which follows a profile. We specify
- # meta_type and interfaces because we don't actually register a
- # class here, only a factory.
- context.registerClass( meta_type='CMF Site'
- , constructors=( addConfiguredSiteForm
- , addConfiguredSite
- )
- , permissions=( 'Add CMF Sites', )
- , interfaces=None
- )
-
- # Since there is no "normal" class registration for Portal.CMFSite,
- # the ZMI icons would disappear without the following icon registration
- registerIcon(Portal.CMFSite, 'images/portal.gif', globals())
-
registerIcon( DefaultWorkflow.DefaultWorkflowDefinition
, 'images/workflow.gif'
, globals()
Deleted: CMF/trunk/CMFDefault/dtml/addPortal.dtml
===================================================================
--- CMF/trunk/CMFDefault/dtml/addPortal.dtml 2005-08-07 16:00:41 UTC (rev 37772)
+++ CMF/trunk/CMFDefault/dtml/addPortal.dtml 2005-08-07 17:01:41 UTC (rev 37773)
@@ -1,126 +0,0 @@
-<dtml-let form_title="'Add Portal'">
-<dtml-if manage_page_header>
- <dtml-var manage_page_header>
- <dtml-var manage_form_title>
-<dtml-else>
- <html><head><title>&dtml-form_title;</title></head>
- <body>
- <h2>&dtml-form_title;</h2>
-</dtml-if>
-</dtml-let>
-
-<form action="manage_addCMFSite" method="POST">
-<table cellspacing="0" cellpadding="2" border="0">
- <tr>
- <td align="left" valign="top" colspan="2">
- <div class="form-help">
- Enter an ID and click the button below to create a new CMF site.
- </div>
- </td>
- </tr>
-
- <tr>
- <td align="left" valign="top">
- <div class="form-label">
- Id
- </div>
- </td>
- <td align="left" valign="top">
- <input type="text" name="id" size="40" />
- </td>
- </tr>
-
- <tr>
- <td align="left" valign="top">
- <div class="form-label">
- Title
- </div>
- </td>
- <td align="left" valign="top">
- <input type="text" name="title" size="40" value="Portal" />
- </td>
- </tr>
-
- <tr>
- <td align="left" valign="top">
- <div class="form-label">
- Membership source
- </div>
- </td>
- <td align="left" valign="top">
- <select name="create_userfolder">
- <option value="1">Create a new user folder in the portal</option>
- <option value="0">I have an existing user folder and want to use it instead</option>
- </select>
- </td>
- </tr>
-
- <tr>
- <td align="left" valign="top">
- <div class="form-label">
- Description
- </div>
- </td>
- <td align="left" valign="top">
- <textarea name="description" cols="60" rows="10"
- style="width: 100%"></textarea>
- </td>
- </tr>
-
-<!-- This may be used in the future.
-
- <tr>
- <td align="left" valign="top">
- <div class="form-label">
- Portal administrator name
- </div>
- </td>
- <td align="left" valign="top">
- <input type="text" name="email_from_name" size="40"
- value="Portal Administrator" />
- </td>
- </tr>
-
- <tr>
- <td align="left" valign="top">
- <div class="form-label">
- Portal administrator e-mail address
- </div>
- </td>
- <td align="left" valign="top">
- <input type="text" name="email_from_address" size="40"
- value="postmaster at localhost"/>
- </td>
- </tr>
-
- <tr>
- <td align="left" valign="top">
- <div class="form-label"><label for="cb_valemail">
- Validate e-mail addresses
- </label></div>
- </td>
- <td align="left" valign="top">
- <input type="checkbox" name="validate_email" value="1" id="cb_valemail" />
- </td>
- </tr>
-
--->
-
- <tr>
- <td align="left" valign="top">
- </td>
- <td align="left" valign="top">
- <div class="form-element">
- <input class="form-element" type="submit" name="submit"
- value=" Add " />
- </div>
- </td>
- </tr>
-</table>
-</form>
-
-<dtml-if manage_page_footer>
- <dtml-var manage_page_footer>
-<dtml-else>
- </body></html>
-</dtml-if>
Copied: CMF/trunk/CMFDefault/factory.py (from rev 37772, CMF/trunk/CMFSetup/factory.py)
===================================================================
--- CMF/trunk/CMFSetup/factory.py 2005-08-07 16:00:41 UTC (rev 37772)
+++ CMF/trunk/CMFDefault/factory.py 2005-08-07 17:01:41 UTC (rev 37773)
@@ -0,0 +1,70 @@
+##############################################################################
+#
+# Copyright (c) 2004 Zope Corporation and Contributors. All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+""" Configured site factory implementation.
+
+$Id$
+"""
+
+from Products.PageTemplates.PageTemplateFile import PageTemplateFile
+
+from Products.CMFCore.utils import getToolByName
+from Products.CMFSetup import EXTENSION
+from Products.CMFSetup import profile_registry
+from Products.CMFSetup.tool import SetupTool
+
+from Portal import CMFSite
+from utils import _wwwdir
+
+
+def addConfiguredSiteForm(dispatcher):
+ """ Wrap the PTF in 'dispatcher', including 'profile_registry' in options.
+ """
+ wrapped = PageTemplateFile( 'siteAddForm', _wwwdir ).__of__( dispatcher )
+
+ base_profiles = []
+ extension_profiles = []
+
+ for info in profile_registry.listProfileInfo():
+ if info.get('type') == EXTENSION:
+ extension_profiles.append(info)
+ else:
+ base_profiles.append(info)
+
+ return wrapped( base_profiles=tuple(base_profiles),
+ extension_profiles =tuple(extension_profiles) )
+
+def addConfiguredSite(dispatcher, site_id, profile_id, snapshot=True,
+ RESPONSE=None, extension_ids=()):
+ """ Add a CMFSite to 'dispatcher', configured according to 'profile_id'.
+ """
+ site = CMFSite( site_id )
+ dispatcher._setObject( site_id, site )
+ site = dispatcher._getOb( site_id )
+
+ setup_tool = SetupTool()
+ site._setObject( 'portal_setup', setup_tool )
+ setup_tool = getToolByName( site, 'portal_setup' )
+
+ setup_tool.setImportContext( 'profile-%s' % profile_id )
+ setup_tool.runAllImportSteps()
+ for extension_id in extension_ids:
+ setup_tool.setImportContext( 'profile-%s' % extension_id )
+ setup_tool.runAllImportSteps()
+ setup_tool.setImportContext( 'profile-%s' % profile_id )
+
+ if snapshot is True:
+ setup_tool.createSnapshot( 'initial_configuration' )
+
+ if RESPONSE is not None:
+ RESPONSE.redirect( '%s/manage_main?update_menu=1'
+ % dispatcher.absolute_url() )
Modified: CMF/trunk/CMFDefault/tests/test_Portal.py
===================================================================
--- CMF/trunk/CMFDefault/tests/test_Portal.py 2005-08-07 16:00:41 UTC (rev 37772)
+++ CMF/trunk/CMFDefault/tests/test_Portal.py 2005-08-07 17:01:41 UTC (rev 37773)
@@ -29,7 +29,7 @@
def _makeSite( self, id='testsite' ):
- from Products.CMFSetup.factory import addConfiguredSite
+ from Products.CMFDefault.factory import addConfiguredSite
addConfiguredSite(self.root, id, 'CMFDefault:default', snapshot=False)
return getattr( self.root, id )
Modified: CMF/trunk/CMFDefault/utils.py
===================================================================
--- CMF/trunk/CMFDefault/utils.py 2005-08-07 16:00:41 UTC (rev 37772)
+++ CMF/trunk/CMFDefault/utils.py 2005-08-07 17:01:41 UTC (rev 37773)
@@ -33,6 +33,7 @@
security.declarePrivate('_dtmldir')
_dtmldir = os.path.join( package_home( globals() ), 'dtml' )
+_wwwdir = os.path.join( package_home( globals() ), 'www' )
security.declarePublic('formatRFC822Headers')
def formatRFC822Headers( headers ):
Copied: CMF/trunk/CMFDefault/www/siteAddForm.zpt (from rev 37772, CMF/trunk/CMFSetup/www/siteAddForm.zpt)
Deleted: CMF/trunk/CMFSetup/factory.py
===================================================================
--- CMF/trunk/CMFSetup/factory.py 2005-08-07 16:00:41 UTC (rev 37772)
+++ CMF/trunk/CMFSetup/factory.py 2005-08-07 17:01:41 UTC (rev 37773)
@@ -1,76 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2004 Zope Corporation and Contributors. All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-""" Configured site factory implementation.
-
-$Id$
-"""
-
-from Products.PageTemplates.PageTemplateFile import PageTemplateFile
-
-from Products.CMFCore.utils import getToolByName
-from Products.CMFDefault.Portal import CMFSite
-
-from interfaces import EXTENSION
-from registry import _profile_registry as profile_registry
-from tool import SetupTool
-from utils import _wwwdir
-
-def addConfiguredSiteForm( dispatcher ):
-
- """ Wrap the PTF in 'dispatcher', including 'profile_registry' in options.
- """
- wrapped = PageTemplateFile( 'siteAddForm', _wwwdir ).__of__( dispatcher )
-
- base_profiles = []
- extension_profiles = []
-
- for info in profile_registry.listProfileInfo():
- if info.get('type') == EXTENSION:
- extension_profiles.append(info)
- else:
- base_profiles.append(info)
-
- return wrapped( base_profiles=tuple(base_profiles),
- extension_profiles =tuple(extension_profiles) )
-
-def addConfiguredSite( dispatcher
- , site_id
- , profile_id
- , snapshot=True
- , RESPONSE=None
- , extension_ids=()
- ):
-
- """ Add a CMFSite to 'dispatcher', configured according to 'profile_id'.
- """
- site = CMFSite( site_id )
- dispatcher._setObject( site_id, site )
- site = dispatcher._getOb( site_id )
-
- setup_tool = SetupTool()
- site._setObject( 'portal_setup', setup_tool )
- setup_tool = getToolByName( site, 'portal_setup' )
-
- setup_tool.setImportContext( 'profile-%s' % profile_id )
- setup_tool.runAllImportSteps()
- for extension_id in extension_ids:
- setup_tool.setImportContext( 'profile-%s' % extension_id )
- setup_tool.runAllImportSteps()
- setup_tool.setImportContext( 'profile-%s' % profile_id )
-
- if snapshot is True:
- setup_tool.createSnapshot( 'initial_configuration' )
-
- if RESPONSE is not None:
- RESPONSE.redirect( '%s/manage_main?update_menu=1'
- % dispatcher.absolute_url() )
Deleted: CMF/trunk/CMFSetup/www/siteAddForm.zpt
===================================================================
--- CMF/trunk/CMFSetup/www/siteAddForm.zpt 2005-08-07 16:00:41 UTC (rev 37772)
+++ CMF/trunk/CMFSetup/www/siteAddForm.zpt 2005-08-07 17:01:41 UTC (rev 37773)
@@ -1,51 +0,0 @@
-<h1 tal:replace="structure context/manage_page_header">PAGE HEADER</h1>
-<h2 tal:define="form_title string:Add CMF Site"
- tal:replace="structure context/manage_form_title">FORM TITLE</h2>
-
-<p class="form-help">Please select ID and configuration for the new site.</p>
-
-<form action="addConfiguredSite" method="post">
-<table cellspacing="0" cellpadding="2" border="0">
- <tr valign="top">
- <td>
- <div class="form-label">Site ID</div>
- </td>
- <td>
- <input type="text" name="site_id" />
- </td>
- </tr>
- <tr valign="top">
- <td>
- <div class="form-label">Setup profile</div>
- </td>
- <td>
- <select name="profile_id">
- <option value="PROFILE_ID"
- tal:repeat="info options/base_profiles"
- tal:attributes="value info/id"
- tal:content="info/title">PROFILE TITLE</option>
- </select>
- </td>
- </tr>
- <tr valign="top">
- <td>
- <div class="form-label">Optional extensions</div>
- </td>
- <td><tal:span tal:repeat="info options/extension_profiles">
- <input type="checkbox" name="extension_ids:list" value="PROFILE_ID"
- tal:attributes="value info/id" />
- <tal:span tal:content="info/title">PROFILE TITLE</tal:span><br /></tal:span>
- </td>
- </tr>
- <tr>
- <td>
-
- </td>
- <td>
- <input class="form-element" type="submit" name="submit" value="Add" />
- </td>
- </tr>
-</table>
-</form>
-
-<h1 tal:replace="structure context/manage_page_footer">PAGE FOOTER</h1>
More information about the CMF-checkins
mailing list