Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Private Member Functions
CMFTestCase.setup.SiteSetup Class Reference
Inheritance diagram for CMFTestCase.setup.SiteSetup:
Inheritance graph
[legend]

List of all members.

Public Member Functions

def __init__
def run

Public Attributes

 id
 products
 quiet
 base_profile
 extension_profiles
 app

Private Member Functions

def _setupCMFSite
def _setupCMFSite_with_genericsetup
def _setupCMFSite_with_portalgenerator
def _setupRegistries
def _setupProfiles
def _setupProducts
def _placefulSetUp
def _placefulTearDown
def _optimize
def _app
def _close
def _login
def _logout
def _commit
def _abort
def _print

Detailed Description

Creates a CMF site and/or installs products into it.

Definition at line 122 of file setup.py.


Constructor & Destructor Documentation

def CMFTestCase.setup.SiteSetup.__init__ (   self,
  id,
  products,
  quiet,
  base_profile,
  extension_profiles 
)

Definition at line 125 of file setup.py.

00125 
00126     def __init__(self, id, products, quiet, base_profile, extension_profiles):
00127         self.id = id
00128         self.products = products
00129         self.quiet = quiet
00130         self.base_profile = base_profile
00131         self.extension_profiles = tuple(extension_profiles)


Member Function Documentation

def CMFTestCase.setup.SiteSetup._abort (   self) [private]
Aborts the transaction.

Definition at line 267 of file setup.py.

00267 
00268     def _abort(self):
00269         '''Aborts the transaction.'''
00270         transaction.abort()

def CMFTestCase.setup.SiteSetup._app (   self) [private]
Opens a ZODB connection and returns the app object.

Definition at line 246 of file setup.py.

00246 
00247     def _app(self):
00248         '''Opens a ZODB connection and returns the app object.'''
00249         return ZopeTestCase.app()

def CMFTestCase.setup.SiteSetup._close (   self) [private]
Closes the ZODB connection.

Definition at line 250 of file setup.py.

00250 
00251     def _close(self):
00252         '''Closes the ZODB connection.'''
00253         ZopeTestCase.close(self.app)

def CMFTestCase.setup.SiteSetup._commit (   self) [private]
Commits the transaction.

Definition at line 263 of file setup.py.

00263 
00264     def _commit(self):
00265         '''Commits the transaction.'''
00266         transaction.commit()

Here is the caller graph for this function:

def CMFTestCase.setup.SiteSetup._login (   self,
  uf,
  name 
) [private]
Logs in as user 'name' from user folder 'uf'.

Definition at line 254 of file setup.py.

00254 
00255     def _login(self, uf, name):
00256         '''Logs in as user 'name' from user folder 'uf'.'''
00257         user = uf.getUserById(name).__of__(uf)
00258         newSecurityManager(None, user)

def CMFTestCase.setup.SiteSetup._logout (   self) [private]
Logs out.

Definition at line 259 of file setup.py.

00259 
00260     def _logout(self):
00261         '''Logs out.'''
00262         noSecurityManager()

def CMFTestCase.setup.SiteSetup._optimize (   self) [private]
Applies optimizations to the PortalGenerator.

Definition at line 242 of file setup.py.

00242 
00243     def _optimize(self):
00244         '''Applies optimizations to the PortalGenerator.'''
00245         _optimize()

Sets the local site/manager.

Definition at line 231 of file setup.py.

00231 
00232     def _placefulSetUp(self):
00233         '''Sets the local site/manager.'''
00234         if CMF21:
00235             portal = getattr(self.app, self.id)
00236             _placefulSetUp(portal)

Resets the local site/manager.

Definition at line 237 of file setup.py.

00237 
00238     def _placefulTearDown(self):
00239         '''Resets the local site/manager.'''
00240         if CMF21:
00241             _placefulTearDown()

def CMFTestCase.setup.SiteSetup._print (   self,
  msg 
) [private]
Prints msg to stderr.

Definition at line 271 of file setup.py.

00271 
00272     def _print(self, msg):
00273         '''Prints msg to stderr.'''
00274         if not self.quiet:
00275             ZopeTestCase._print(msg)
00276 

Here is the caller graph for this function:

Creates the CMF site.

Definition at line 157 of file setup.py.

00157 
00158     def _setupCMFSite(self):
00159         '''Creates the CMF site.'''
00160         if CMF16:
00161             self._setupCMFSite_with_genericsetup()
00162         else:
00163             self._setupCMFSite_with_portalgenerator()

Here is the call graph for this function:

Creates the site using GenericSetup.

Definition at line 164 of file setup.py.

00164 
00165     def _setupCMFSite_with_genericsetup(self):
00166         '''Creates the site using GenericSetup.'''
00167         start = time()
00168         if self.base_profile != default_base_profile:
00169             self._print('Adding CMF Site (%s) ... ' % (self.base_profile,))
00170         else:
00171             self._print('Adding CMF Site ... ')
00172         factory.addConfiguredSite(self.app, self.id, snapshot=0,
00173                                   profile_id=self.base_profile)
00174         self._commit()
00175         self._print('done (%.3fs)\n' % (time()-start,))

Here is the call graph for this function:

Here is the caller graph for this function:

Creates the site using PortalGenerator.

Definition at line 176 of file setup.py.

00176 
00177     def _setupCMFSite_with_portalgenerator(self):
00178         '''Creates the site using PortalGenerator.'''
00179         start = time()
00180         self._print('Adding CMF Site ... ')
00181         from Products.CMFDefault.Portal import manage_addCMFSite
00182         manage_addCMFSite(self.app, self.id, create_userfolder=1)
00183         self._commit()
00184         self._print('done (%.3fs)\n' % (time()-start,))

Here is the call graph for this function:

Here is the caller graph for this function:

Installs products into the site.

Definition at line 218 of file setup.py.

00218 
00219     def _setupProducts(self):
00220         '''Installs products into the site.'''
00221         portal = getattr(self.app, self.id)
00222         for product in self.products:
00223             if not portal._installed_products.has_key(product):
00224                 start = time()
00225                 self._print('Adding %s ... ' % (product,))
00226                 exec 'from Products.%s.Extensions.Install import install' % (product,)
00227                 install(portal)
00228                 portal._installed_products[product] = 1
00229                 self._commit()
00230                 self._print('done (%.3fs)\n' % (time()-start,))

Here is the call graph for this function:

Imports extension profiles into the site.

Definition at line 195 of file setup.py.

00195 
00196     def _setupProfiles(self):
00197         '''Imports extension profiles into the site.'''
00198         portal = getattr(self.app, self.id)
00199         setup = getattr(portal, 'portal_setup', None)
00200         if setup is not None:
00201             for profile in self.extension_profiles:
00202                 if not portal._installed_profiles.has_key(profile):
00203                     start = time()
00204                     self._print('Adding %s ... ' % (profile,))
00205                     profile_id = 'profile-%s' % (profile,)
00206                     if CMF21:
00207                         setup.runAllImportStepsFromProfile(profile_id)
00208                     else:
00209                         saved = setup.getImportContextID()
00210                         try:
00211                             setup.setImportContext(profile_id)
00212                             setup.runAllImportSteps()
00213                         finally:
00214                             setup.setImportContext(saved)
00215                     portal._installed_profiles[profile] = 1
00216                     self._commit()
00217                     self._print('done (%.3fs)\n' % (time()-start,))

Here is the call graph for this function:

Installs persistent registries.

Definition at line 185 of file setup.py.

00185 
00186     def _setupRegistries(self):
00187         '''Installs persistent registries.'''
00188         portal = getattr(self.app, self.id)
00189         if not hasattr(portal, '_installed_profiles'):
00190             portal._installed_profiles = PersistentMapping()
00191             self._commit()
00192         if not hasattr(portal, '_installed_products'):
00193             portal._installed_products = PersistentMapping()
00194             self._commit()

Here is the call graph for this function:

Reimplemented in CMFTestCase.setup.SiteCleanup.

Definition at line 132 of file setup.py.

00132 
00133     def run(self):
00134         self.app = self._app()
00135         try:
00136             uf = self.app.acl_users
00137             if uf.getUserById(portal_owner) is None:
00138                 # Add portal owner
00139                 uf.userFolderAddUser(portal_owner, default_password, ['Manager'], [])
00140             if not hasattr(aq_base(self.app), self.id):
00141                 # Add site
00142                 self._login(uf, portal_owner)
00143                 self._optimize()
00144                 self._setupCMFSite()
00145                 self._setupRegistries()
00146             if hasattr(aq_base(self.app), self.id):
00147                 # Configure site
00148                 self._login(uf, portal_owner)
00149                 self._placefulSetUp()
00150                 self._setupProfiles()
00151                 self._setupProducts()
00152         finally:
00153             self._abort()
00154             self._close()
00155             self._logout()
00156             self._placefulTearDown()


Member Data Documentation

Reimplemented in CMFTestCase.setup.SiteCleanup.

Definition at line 133 of file setup.py.

Definition at line 129 of file setup.py.

Definition at line 130 of file setup.py.

Reimplemented in CMFTestCase.setup.SiteCleanup.

Definition at line 126 of file setup.py.

Definition at line 127 of file setup.py.

Definition at line 128 of file setup.py.


The documentation for this class was generated from the following file: