Changeset 51312

Show
Ignore:
Timestamp:
03/09/07 12:36:13 (2 years ago)
Author:
madarche
Message:

- Added the possibility to create any objects at the root of a CPS site

(for example Zope objects such as cache managers) by specifying them in
profiles/default/roots.xml. Previously it was limited to only CPS objects.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • CPS3/products/CPSDefault/trunk/CHANGES

    r51244 r51312  
    44New features 
    55~~~~~~~~~~~~ 
    6 
     6- Added the possibility to create any objects at the root of a CPS site 
     7  (for example Zope objects such as cache managers) by specifying them in 
     8  profiles/default/roots.xml. Previously it was limited to only CPS objects. 
    79Bug fixes 
    810~~~~~~~~~ 
  • CPS3/products/CPSDefault/trunk/exportimport.py

    r50176 r51312  
    1 # (C) Copyright 2005-2006 Nuxeo SAS <http://nuxeo.com> 
    2 # Author: Florent Guillaume <fg@nuxeo.com> 
     1# (C) Copyright 2005-2007 Nuxeo SAS <http://nuxeo.com> 
     2# Authors: 
     3# Florent Guillaume <fg@nuxeo.com> 
     4# M.-A. Darche <madarche@nuxeo.com> 
    35# 
    46# This program is free software; you can redistribute it and/or modify 
     
    2123 
    2224from Acquisition import aq_base 
     25 
     26import Products 
     27 
    2328from Products.StandardCacheManagers.AcceleratedHTTPCacheManager \ 
    2429     import AcceleratedHTTPCacheManager 
    2530from Products.CMFCore.utils import getToolByName 
     31 
     32from Products.GenericSetup.utils import CONVERTER, DEFAULT, KEY 
    2633from Products.GenericSetup.utils import XMLAdapterBase 
    2734from Products.GenericSetup.utils import ObjectManagerHelpers 
    2835from Products.GenericSetup.utils import ImportConfiguratorBase 
    29 from Products.GenericSetup.utils import CONVERTER, DEFAULT, KEY 
     36from Products.GenericSetup.utils import importObjects 
    3037 
    3138from Products.CPSCore.utils import ALL_LOCALES 
     
    7178        self.setupTranslationService() 
    7279        self.setupRoots() 
    73         self.setupFCKeditorHttpCache() 
    7480        self.setupDefaultRoles() 
    7581        return "Various settings imported." 
     
    104110        importer.body = body 
    105111 
    106     def setupFCKeditorHttpCache(self): 
    107         if 'FckHTTPCache' in self.site.objectIds(): 
    108             return 
    109         self.site._setObject('FckHTTPCache', 
    110                              AcceleratedHTTPCacheManager('FckHTTPCache')) 
    111         cache_settings = {'anonymous_only' : 0, 
    112                           'notify_urls' : (), 
    113                           'interval' :1728000 
    114                           } 
    115         self.site.FckHTTPCache.manage_editProps('FCK Http Cache', 
    116                                                 settings=cache_settings) 
    117  
    118112 
    119113# Called according to import_steps.xml 
     
    157151 
    158152            id = str(child.getAttribute('name')) 
     153            portal_type = str(child.getAttribute('portal_type')) 
     154            meta_type = str(child.getAttribute('meta_type')) 
    159155 
    160156            # Create object if needed 
    161157            if getattr(aq_base(site), id, None) is None: 
    162                 portal_type = str(child.getAttribute('portal_type')) 
    163                 language = str(child.getAttribute('language')) 
    164                 if language not in avail_langs: 
    165                     language = None 
    166                 wftool = getToolByName(site, 'portal_workflow') 
    167                 wftool.invokeFactoryFor(site, portal_type, id, 
    168                                         language=language) 
    169             proxy = site._getOb(id) 
    170  
    171             # Placeful configuration for one root (and creates subobjects) 
    172             path = self.path+'/'+id 
    173             filename = path+'.xml' 
     158                # If this is a CPS document such as a Workspace or a Section 
     159                if portal_type: 
     160                    language = str(child.getAttribute('language')) 
     161                    if language not in avail_langs: 
     162                        language = None 
     163                    wftool = getToolByName(site, 'portal_workflow') 
     164                    wftool.invokeFactoryFor(site, portal_type, id, 
     165                                            language=language) 
     166                else: 
     167                    # This is not a CPS document such as a Workspace or a 
     168                    # Section and thus it can be dealt with in a generic manner. 
     169                    for mt_info in Products.meta_types: 
     170                        if mt_info['name'] == meta_type: 
     171                            site._setObject(id, mt_info['instance'](id)) 
     172                            break 
     173                    else: 
     174                        raise ValueError("unknown meta_type '%s'" % meta_type) 
     175 
     176            obj = site._getOb(id) 
     177 
     178            if not portal_type: 
     179                #self._logger.debug( 
     180                #    "_initRoots importObjects on %s with parent_path = %s" 
     181                #    % (str(obj), self.path)) 
     182                # Import subobjects recursively 
     183                importObjects(obj, self.path + '/', self.environ) 
     184                # Move on to the next root object 
     185                continue 
     186 
     187            # Placeful configuration for one root object 
     188            # (and subobjects creation). 
     189            path = self.path + '/' + id 
     190            filename = path + '.xml' 
     191 
    174192            body = self.environ.readDataFile(filename) 
    175193            if body is not None: 
    176                 importer = RootXMLAdapter(proxy, self.environ) 
     194                importer = RootXMLAdapter(obj, self.environ) 
    177195                importer.path = path # to load rolemap contextually 
    178196                importer.filename = filename # for error reporting 
     
    180198 
    181199            # Recurse into configuration objects 
    182             for subid, subob in proxy.objectItems(): 
     200            for subid, subob in obj.objectItems(): 
    183201                if subid.startswith('.'): 
    184                     importCPSObjects(subob, path+'/', self.environ) 
    185  
    186             # Recursively load sub proxy folders 
     202                    importCPSObjects(subob, path + '/', self.environ) 
     203 
     204            # Recursively load sub obj folders 
    187205            filename = path + '/' + self.name +  '.xml' 
    188206            body = self.environ.readDataFile(filename) 
    189207            if body is not None: 
    190                 importer = RootsXMLAdapter(proxy, self.environ) 
     208                importer = RootsXMLAdapter(obj, self.environ) 
    191209                importer.path = path + '/' + self.name 
    192210                importer.filename = filename # for error reporting 
  • CPS3/products/CPSDefault/trunk/profiles/default/roots.xml

    r32410 r51312  
    44 <object name="sections" portal_type="Section"/> 
    55 <object name="workspaces" portal_type="Workspace"/> 
     6 <object name="FckHTTPCache" meta_type="Accelerated HTTP Cache Manager"/> 
     7 <!-- 
     8 <object name="portlet_lookup_ramcache" meta_type="RAM Cache Manager"/> 
     9 --> 
    610</roots>