Back to index

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

List of all members.

Public Member Functions

def __init__
def run

Public Attributes

 id
 policy
 products
 quiet
 with_default_memberarea
 base_profile
 extension_profiles
 app

Private Member Functions

def _setupPloneSite
def _setupPloneSite_with_genericsetup
def _setupPloneSite_with_portalgenerator
def _setupRegistries
def _setupProfiles
def _setupProducts
def _setupHomeFolder
def _setupCreatedHook
def _placefulSetUp
def _placefulTearDown
def _optimize
def _app
def _close
def _login
def _logout
def _commit
def _abort
def _print

Detailed Description

Creates a Plone site and/or quickinstalls products into it.

Definition at line 183 of file setup.py.


Constructor & Destructor Documentation

def PloneTestCase.setup.SiteSetup.__init__ (   self,
  id,
  policy,
  products,
  quiet,
  with_default_memberarea,
  base_profile,
  extension_profiles 
)

Definition at line 187 of file setup.py.

00187 
00188                  base_profile, extension_profiles):
00189         self.id = id
00190         self.policy = policy
00191         self.products = products
00192         self.quiet = quiet
00193         self.with_default_memberarea = with_default_memberarea
00194         self.base_profile = base_profile
00195         self.extension_profiles = tuple(extension_profiles)


Member Function Documentation

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

Definition at line 356 of file setup.py.

00356 
00357     def _abort(self):
00358         '''Aborts the transaction.'''
00359         transaction.abort()

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

Definition at line 335 of file setup.py.

00335 
00336     def _app(self):
00337         '''Opens a ZODB connection and returns the app object.'''
00338         return ZopeTestCase.app()

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

Definition at line 339 of file setup.py.

00339 
00340     def _close(self):
00341         '''Closes the ZODB connection.'''
00342         ZopeTestCase.close(self.app)

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

Definition at line 352 of file setup.py.

00352 
00353     def _commit(self):
00354         '''Commits the transaction.'''
00355         transaction.commit()

Here is the caller graph for this function:

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

Definition at line 343 of file setup.py.

00343 
00344     def _login(self, uf, name):
00345         '''Logs in as user 'name' from user folder 'uf'.'''
00346         user = uf.getUserById(name).__of__(uf)
00347         newSecurityManager(None, user)

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

Definition at line 348 of file setup.py.

00348 
00349     def _logout(self):
00350         '''Logs out.'''
00351         noSecurityManager()

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

Definition at line 331 of file setup.py.

00331 
00332     def _optimize(self):
00333         '''Applies optimizations to the PortalGenerator.'''
00334         _optimize()

Sets the local site/manager.

Definition at line 320 of file setup.py.

00320 
00321     def _placefulSetUp(self):
00322         '''Sets the local site/manager.'''
00323         if PLONE30:
00324             portal = getattr(self.app, self.id)
00325             _placefulSetUp(portal)

Resets the local site/manager.

Definition at line 326 of file setup.py.

00326 
00327     def _placefulTearDown(self):
00328         '''Resets the local site/manager.'''
00329         if PLONE30:
00330             _placefulTearDown()

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

Definition at line 360 of file setup.py.

00360 
00361     def _print(self, msg):
00362         '''Prints msg to stderr.'''
00363         if not self.quiet:
00364             ZopeTestCase._print(msg)
00365 

Here is the caller graph for this function:

Registers a handler for ISiteManagerCreatedEvent.

Definition at line 313 of file setup.py.

00313 
00314     def _setupCreatedHook(self):
00315         '''Registers a handler for ISiteManagerCreatedEvent.'''
00316         from zope.component import getGlobalSiteManager
00317         from Products.CMFPlone.interfaces import ISiteManagerCreatedEvent
00318         gsm = getGlobalSiteManager()
00319         gsm.registerHandler(_placefulSetUpHandler, (ISiteManagerCreatedEvent,))

Here is the caller graph for this function:

Creates the default user's member folder.

Definition at line 308 of file setup.py.

00308 
00309     def _setupHomeFolder(self):
00310         '''Creates the default user's member folder.'''
00311         portal = getattr(self.app, self.id)
00312         _createHomeFolder(portal, default_user, take_ownership=0)

Here is the call graph for this function:

Here is the caller graph for this function:

Creates the Plone site.

Definition at line 221 of file setup.py.

00221 
00222     def _setupPloneSite(self):
00223         '''Creates the Plone site.'''
00224         if PLONE30:
00225             self._setupCreatedHook()
00226         if PLONE25:
00227             self._setupPloneSite_with_genericsetup()
00228         else:
00229             self._setupPloneSite_with_portalgenerator()

Here is the call graph for this function:

Creates the site using GenericSetup.

Definition at line 230 of file setup.py.

00230 
00231     def _setupPloneSite_with_genericsetup(self):
00232         '''Creates the site using GenericSetup.'''
00233         start = time()
00234         if self.base_profile != default_base_profile:
00235             self._print('Adding Plone Site (%s) ... ' % (self.base_profile,))
00236         else:
00237             self._print('Adding Plone Site ... ')
00238         # Add Plone site
00239         factory = self.app.manage_addProduct['CMFPlone']
00240         factory.addPloneSite(self.id, create_userfolder=1, snapshot=0,
00241                              profile_id=self.base_profile)
00242         # Pre-create default memberarea to speed up the tests
00243         if self.with_default_memberarea:
00244             self._setupHomeFolder()
00245         self._commit()
00246         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 247 of file setup.py.

00247 
00248     def _setupPloneSite_with_portalgenerator(self):
00249         '''Creates the site using PortalGenerator.'''
00250         start = time()
00251         if self.policy != default_policy:
00252             self._print('Adding Plone Site (%s) ... ' % (self.policy,))
00253         else:
00254             self._print('Adding Plone Site ... ')
00255         # Add Plone site
00256         factory = self.app.manage_addProduct['CMFPlone']
00257         factory.manage_addSite(self.id, create_userfolder=1, custom_policy=self.policy)
00258         # Pre-create default memberarea to speed up the tests
00259         if self.with_default_memberarea:
00260             self._setupHomeFolder()
00261         self._commit()
00262         self._print('done (%.3fs)\n' % (time()-start,))

Here is the call graph for this function:

Here is the caller graph for this function:

Quickinstalls products into the site.

Definition at line 293 of file setup.py.

00293 
00294     def _setupProducts(self):
00295         '''Quickinstalls products into the site.'''
00296         portal = getattr(self.app, self.id)
00297         qi = portal.portal_quickinstaller
00298         for product in self.products:
00299             if not qi.isProductInstalled(product):
00300                 if qi.isProductInstallable(product):
00301                     start = time()
00302                     self._print('Adding %s ... ' % (product,))
00303                     qi.installProduct(product)
00304                     self._commit()
00305                     self._print('done (%.3fs)\n' % (time()-start,))
00306                 else:
00307                     self._print('Adding %s ... NOT INSTALLABLE\n' % (product,))

Here is the call graph for this function:

Imports extension profiles into the site.

Definition at line 270 of file setup.py.

00270 
00271     def _setupProfiles(self):
00272         '''Imports extension profiles into the site.'''
00273         portal = getattr(self.app, self.id)
00274         setup = getattr(portal, 'portal_setup', None)
00275         if setup is not None:
00276             for profile in self.extension_profiles:
00277                 if not portal._installed_profiles.has_key(profile):
00278                     start = time()
00279                     self._print('Adding %s ... ' % (profile,))
00280                     profile_id = 'profile-%s' % (profile,)
00281                     if PLONE30:
00282                         setup.runAllImportStepsFromProfile(profile_id)
00283                     else:
00284                         saved = setup.getImportContextID()
00285                         try:
00286                             setup.setImportContext(profile_id)
00287                             setup.runAllImportSteps()
00288                         finally:
00289                             setup.setImportContext(saved)
00290                     portal._installed_profiles[profile] = 1
00291                     self._commit()
00292                     self._print('done (%.3fs)\n' % (time()-start,))

Here is the call graph for this function:

Installs persistent registries.

Definition at line 263 of file setup.py.

00263 
00264     def _setupRegistries(self):
00265         '''Installs persistent registries.'''
00266         portal = getattr(self.app, self.id)
00267         if not hasattr(portal, '_installed_profiles'):
00268             portal._installed_profiles = PersistentMapping()
00269             self._commit()

Here is the call graph for this function:

Reimplemented in PloneTestCase.setup.SiteCleanup.

Definition at line 196 of file setup.py.

00196 
00197     def run(self):
00198         self.app = self._app()
00199         try:
00200             uf = self.app.acl_users
00201             if uf.getUserById(portal_owner) is None:
00202                 # Add portal owner
00203                 uf.userFolderAddUser(portal_owner, default_password, ['Manager'], [])
00204             if not hasattr(aq_base(self.app), self.id):
00205                 # Add site
00206                 self._login(uf, portal_owner)
00207                 self._optimize()
00208                 self._setupPloneSite()
00209                 self._setupRegistries()
00210             if hasattr(aq_base(self.app), self.id):
00211                 # Configure site
00212                 self._login(uf, portal_owner)
00213                 self._placefulSetUp()
00214                 self._setupProfiles()
00215                 self._setupProducts()
00216         finally:
00217             self._abort()
00218             self._placefulTearDown()
00219             self._close()
00220             self._logout()


Member Data Documentation

Reimplemented in PloneTestCase.setup.SiteCleanup.

Definition at line 197 of file setup.py.

Definition at line 193 of file setup.py.

Definition at line 194 of file setup.py.

Reimplemented in PloneTestCase.setup.SiteCleanup.

Definition at line 188 of file setup.py.

Definition at line 189 of file setup.py.

Definition at line 190 of file setup.py.

Definition at line 191 of file setup.py.

Definition at line 192 of file setup.py.


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