Back to index

plone3  3.1.7
Public Member Functions
CMFPlone.setuphandlers.PloneGenerator Class Reference

List of all members.

Public Member Functions

def installArchetypes
def installProducts
def installDependencies
def addCacheHandlers
def addCacheForResourceRegistry
def setupPortalContent
def performMigrationActions
def enableSyndication
def enableSite
def assignTitles

Detailed Description

Definition at line 81 of file setuphandlers.py.


Member Function Documentation

Definition at line 122 of file setuphandlers.py.

00122 
00123     def addCacheForResourceRegistry(self, portal):
00124         ram_cache_id = 'ResourceRegistryCache'
00125         if ram_cache_id in portal.objectIds():
00126             cache = getattr(portal, ram_cache_id)
00127             settings = cache.getSettings()
00128             settings['max_age'] = 24*3600 # keep for up to 24 hours
00129             settings['request_vars'] = ('URL',)
00130             cache.manage_editProps('Cache for saved ResourceRegistry files', settings)
00131         reg = getToolByName(portal, 'portal_css', None)
00132         if reg is not None and getattr(aq_base(reg), 'ZCacheable_setManagerId', None) is not None:
00133             reg.ZCacheable_setManagerId(ram_cache_id)
00134             reg.ZCacheable_setEnabled(1)
00135 
00136         reg = getToolByName(portal, 'portal_kss', None)
00137         if reg is not None and getattr(aq_base(reg), 'ZCacheable_setManagerId', None) is not None:
00138             reg.ZCacheable_setManagerId(ram_cache_id)
00139             reg.ZCacheable_setEnabled(1)
00140 
00141         reg = getToolByName(portal, 'portal_javascripts', None)
00142         if reg is not None and getattr(aq_base(reg), 'ZCacheable_setManagerId', None) is not None:
00143             reg.ZCacheable_setManagerId(ram_cache_id)
00144             reg.ZCacheable_setEnabled(1)

Here is the call graph for this function:

Add RAM and AcceleratedHTTP cache handlers 

Definition at line 106 of file setuphandlers.py.

00106 
00107     def addCacheHandlers(self, p):
00108         """ Add RAM and AcceleratedHTTP cache handlers """
00109         mgrs = [(AcceleratedHTTPCacheManager, 'HTTPCache'),
00110                 (RAMCacheManager, 'RAMCache'),
00111                 (RAMCacheManager, 'ResourceRegistryCache'),
00112                 ]
00113         for mgr_class, mgr_id in mgrs:
00114             existing = p._getOb(mgr_id, None)
00115             if existing is None:
00116                 p._setObject(mgr_id, mgr_class(mgr_id))
00117             else:
00118                 unwrapped = aq_base(existing)
00119                 if not isinstance(unwrapped, mgr_class):
00120                     p._delObject(mgr_id)
00121                     p._setObject(mgr_id, mgr_class(mgr_id))

def CMFPlone.setuphandlers.PloneGenerator.assignTitles (   self,
  portal,
  out 
)

Definition at line 440 of file setuphandlers.py.

00440 
00441     def assignTitles(self, portal, out):
00442         titles={'portal_actions':'Contains custom tabs and buttons',
00443          'portal_membership':'Handles membership policies',
00444          'portal_memberdata':'Handles the available properties on members',
00445          'portal_undo':'Defines actions and functionality related to undo',
00446          'portal_types':'Controls the available content types in your portal',
00447          'plone_utils':'Various utility methods',
00448          'portal_metadata':'Controls metadata like keywords, copyrights, etc',
00449          'portal_migration':'Upgrades to newer Plone versions',
00450          'portal_registration':'Handles registration of new users',
00451          'portal_skins':'Controls skin behaviour (search order etc)',
00452          'portal_syndication':'Generates RSS for folders',
00453          'portal_workflow':'Contains workflow definitions for your portal',
00454          'portal_url':'Methods to anchor you to the root of your Plone site',
00455          'portal_discussion':'Controls how discussions are stored',
00456          'portal_catalog':'Indexes all content in the site',
00457          'portal_factory':'Responsible for the creation of content objects',
00458          'portal_calendar':'Controls how events are shown',
00459          'portal_quickinstaller':'Allows to install/uninstall products',
00460          'portal_interface':'Allows to query object interfaces',
00461          'portal_actionicons':'Associates actions with icons',
00462          'portal_groupdata':'Handles properties on groups',
00463          'portal_groups':'Handles group related functionality',
00464          'translation_service': 'Provides access to the translation machinery',
00465          'mimetypes_registry': 'MIME types recognized by Plone',
00466          'portal_transforms': 'Handles data conversion between MIME types',
00467          }
00468 
00469         for oid in portal.objectIds():
00470             title=titles.get(oid, None)
00471             if title:
00472                 setattr(aq_get(portal, oid), 'title', title)
00473         out.append('Assigned titles to portal tools.')

Make the portal a Zope3 site and create a site manager.

Definition at line 430 of file setuphandlers.py.

00430 
00431     def enableSite(self, portal):
00432         """
00433         Make the portal a Zope3 site and create a site manager.
00434         """
00435         if not ISite.providedBy(portal):
00436             make_objectmanager_site(portal)
00437         # The following event is primarily useful for setting the site hooks
00438         # during test runs.
00439         notify(SiteManagerCreatedEvent(portal))

Here is the call graph for this function:

def CMFPlone.setuphandlers.PloneGenerator.enableSyndication (   self,
  portal,
  out 
)

Definition at line 415 of file setuphandlers.py.

00415 
00416     def enableSyndication(self, portal, out):
00417         syn = getToolByName(portal, 'portal_syndication', None)
00418         if syn is not None:
00419             syn.editProperties(isAllowed=True)
00420             cat = getToolByName(portal, 'portal_catalog', None)
00421             if cat is not None:
00422                 topics = cat(portal_type='Topic')
00423                 for b in topics:
00424                     topic = b.getObject()
00425                     # If syndication is already enabled then another nasty string
00426                     # exception gets raised in CMFDefault
00427                     if topic is not None and not syn.isSyndicationAllowed(topic):
00428                         syn.enableSyndication(topic)
00429                         out.append('Enabled syndication on %s'%b.getPath())

Here is the call graph for this function:

QuickInstaller install of Archetypes and required dependencies.

Definition at line 83 of file setuphandlers.py.

00083 
00084     def installArchetypes(self, p):
00085         """QuickInstaller install of Archetypes and required dependencies."""
00086         qi = getToolByName(p, "portal_quickinstaller")
00087         qi.installProduct('CMFFormController', locked=1, hidden=1, forceProfile=True)
00088         qi.installProduct('MimetypesRegistry', locked=1, hidden=1, forceProfile=True)
00089         qi.installProduct('PortalTransforms', locked=1, hidden=1, forceProfile=True)
00090         qi.installProduct('Archetypes', locked=1, hidden=1,
00091             profile=u'Products.Archetypes:Archetypes')

Here is the call graph for this function:

Definition at line 101 of file setuphandlers.py.

00101 
00102     def installDependencies(self, p):
00103         st=getToolByName(p, "portal_setup")
00104         st.runAllImportStepsFromProfile("profile-Products.CMFPlone:dependencies")
00105 

Here is the call graph for this function:

QuickInstaller install of required Products

Definition at line 92 of file setuphandlers.py.

00092 
00093     def installProducts(self, p):
00094         """QuickInstaller install of required Products"""
00095         qi = getToolByName(p, 'portal_quickinstaller')
00096         qi.installProduct('PlonePAS', locked=1, hidden=1, forceProfile=True)
00097         qi.installProduct('kupu', locked=0, forceProfile=True)
00098         qi.installProduct('CMFDiffTool', locked=0, forceProfile=True)
00099         qi.installProduct('CMFEditions', locked=0, forceProfile=True)
00100         qi.installProduct('PloneLanguageTool', locked=1, hidden=1, forceProfile=True)

Here is the call graph for this function:

Here is the caller graph for this function:

Perform any necessary migration steps.

Definition at line 408 of file setuphandlers.py.

00408 
00409     def performMigrationActions(self, p):
00410         """
00411         Perform any necessary migration steps.
00412         """
00413         mt = queryUtility(IMigrationTool)
00414         mt.setInstanceVersion(mt.getFileSystemVersion())

Import default plone content

Definition at line 146 of file setuphandlers.py.

00146 
00147     def setupPortalContent(self, p):
00148         """
00149         Import default plone content
00150         """
00151         existing = p.objectIds()
00152 
00153         wftool = getToolByName(p, "portal_workflow")
00154 
00155         # Figure out the current user preferred language
00156         language = None
00157         locale = None
00158         target_language = None
00159         request = getattr(p, 'REQUEST', None)
00160         if request is not None:
00161             pl = IUserPreferredLanguages(request)
00162             if pl is not None:
00163                 languages = pl.getPreferredLanguages()
00164                 for httplang in languages:
00165                     parts = (httplang.split('-') + [None, None])[:3]
00166                     try:
00167                         locale = locales.getLocale(*parts)
00168                         break
00169                     except LoadLocaleError:
00170                         # Just try the next combination
00171                         pass
00172                 if len(languages) > 0:
00173                     language = languages[0]
00174 
00175         # Language to be used to translate the content
00176         target_language = language
00177 
00178         # Set the default language of the portal
00179         if language is not None and locale is not None:
00180             localeid = locale.getLocaleID()
00181             base_language = locale.id.language
00182             target_language = localeid
00183 
00184             # If we get a territory, we enable the combined language codes
00185             use_combined = False
00186             if locale.id.territory:
00187                 use_combined = True
00188 
00189             # As we have a sensible language code set now, we disable the
00190             # start neutral functionality
00191             tool = getToolByName(p, "portal_languages")
00192             pprop = getToolByName(p, "portal_properties")
00193             sheet = pprop.site_properties
00194 
00195             tool.manage_setLanguageSettings(language,
00196                 [language],
00197                 setUseCombinedLanguageCodes=use_combined,
00198                 startNeutral=False)
00199 
00200             # Enable visible_ids for non-latin scripts
00201 
00202             # See if we have an url normalizer
00203             normalizer = queryUtility(IURLNormalizer, name=localeid)
00204             if normalizer is None:
00205                 normalizer = queryUtility(IURLNormalizer, name=base_language)
00206 
00207             # If we get a script other than Latn we enable visible_ids
00208             if locale.id.script is not None:
00209                 if locale.id.script.lower() != 'latn':
00210                     sheet.visible_ids = True
00211 
00212             # If we have a normalizer it is safe to disable the visible ids
00213             if normalizer is not None:
00214                 sheet.visible_ids = False
00215 
00216         # Special handling of the front-page, as we want to translate it
00217         if 'front-page' in existing:
00218             fp = p['front-page']
00219             if wftool.getInfoFor(fp, 'review_state') != 'published':
00220                 wftool.doActionFor(fp, 'publish')
00221 
00222             # Show off presentation mode
00223             fp.setPresentation(True)
00224 
00225             # Mark as fully created
00226             fp.unmarkCreationFlag()
00227 
00228             if target_language is not None:
00229                 util = queryUtility(ITranslationDomain, 'plonefrontpage')
00230                 if util is not None:
00231                     front_title = util.translate(u'front-title',
00232                                        target_language=target_language,
00233                                        default="Welcome to Plone")
00234                     front_desc = util.translate(u'front-description',
00235                                        target_language=target_language,
00236                                        default="Congratulations! You have successfully installed Plone.")
00237                     front_text = util.translate(u'front-text',
00238                                        target_language=target_language)
00239                     fp.setLanguage(language)
00240                     fp.setTitle(front_title)
00241                     fp.setDescription(front_desc)
00242                     if front_text != u'front-text':
00243                         fp.setText(front_text)
00244 
00245         # News topic
00246         if 'news' not in existing:
00247             news_title = 'News'
00248             news_desc = 'Site News'
00249             if target_language is not None:
00250                 util = queryUtility(ITranslationDomain, 'plonefrontpage')
00251                 if util is not None:
00252                     news_title = util.translate(u'news-title',
00253                                            target_language=target_language,
00254                                            default='News')
00255                     news_desc = util.translate(u'news-description',
00256                                           target_language=target_language,
00257                                           default='Site News')
00258 
00259             _createObjectByType('Large Plone Folder', p, id='news',
00260                                 title=news_title, description=news_desc)
00261             _createObjectByType('Topic', p.news, id='aggregator',
00262                                 title=news_title, description=news_desc)
00263 
00264             folder = p.news
00265             folder.setConstrainTypesMode(constraintypes.ENABLED)
00266             folder.setLocallyAllowedTypes(['News Item'])
00267             folder.setImmediatelyAddableTypes(['News Item'])
00268             folder.setDefaultPage('aggregator')
00269             folder.unmarkCreationFlag()
00270             if language is not None:
00271                 folder.setLanguage(language)
00272 
00273             if wftool.getInfoFor(folder, 'review_state') != 'published':
00274                 wftool.doActionFor(folder, 'publish')
00275 
00276             topic = p.news.aggregator
00277             if language is not None:
00278                 topic.setLanguage(language)
00279             type_crit = topic.addCriterion('Type','ATPortalTypeCriterion')
00280             type_crit.setValue('News Item')
00281             sort_crit = topic.addCriterion('created','ATSortCriterion')
00282             state_crit = topic.addCriterion('review_state', 'ATSimpleStringCriterion')
00283             state_crit.setValue('published')
00284             topic.setSortCriterion('effective', True)
00285             topic.setLayout('folder_summary_view')
00286             topic.unmarkCreationFlag()
00287 
00288             if wftool.getInfoFor(topic, 'review_state') != 'published':
00289                 wftool.doActionFor(topic, 'publish')
00290 
00291         # Events topic
00292         if 'events' not in existing:
00293             events_title = 'Events'
00294             events_desc = 'Site Events'
00295             if target_language is not None:
00296                 util = queryUtility(ITranslationDomain, 'plonefrontpage')
00297                 if util is not None:
00298                     events_title = util.translate(u'events-title',
00299                                            target_language=target_language,
00300                                            default='Events')
00301                     events_desc = util.translate(u'events-description',
00302                                           target_language=target_language,
00303                                           default='Site Events')
00304 
00305             _createObjectByType('Large Plone Folder', p, id='events',
00306                                 title=events_title, description=events_desc)
00307             _createObjectByType('Topic', p.events, id='aggregator',
00308                                 title=events_title, description=events_desc)
00309             folder = p.events
00310             folder.setConstrainTypesMode(constraintypes.ENABLED)
00311             folder.setLocallyAllowedTypes(['Event'])
00312             folder.setImmediatelyAddableTypes(['Event'])
00313             folder.setDefaultPage('aggregator')
00314             folder.unmarkCreationFlag()
00315             if language is not None:
00316                 folder.setLanguage(language)
00317 
00318             if wftool.getInfoFor(folder, 'review_state') != 'published':
00319                 wftool.doActionFor(folder, 'publish')
00320 
00321             topic = folder.aggregator
00322             topic.unmarkCreationFlag()
00323             if language is not None:
00324                 topic.setLanguage(language)
00325             type_crit = topic.addCriterion('Type','ATPortalTypeCriterion')
00326             type_crit.setValue('Event')
00327             sort_crit = topic.addCriterion('start','ATSortCriterion')
00328             state_crit = topic.addCriterion('review_state', 'ATSimpleStringCriterion')
00329             state_crit.setValue('published')
00330             date_crit = topic.addCriterion('start', 'ATFriendlyDateCriteria')
00331             # Set date reference to now
00332             date_crit.setValue(0)
00333             # Only take events in the future
00334             date_crit.setDateRange('+') # This is irrelevant when the date is now
00335             date_crit.setOperation('more')
00336         else:
00337             topic = p.events
00338 
00339         if wftool.getInfoFor(topic, 'review_state') != 'published':
00340             wftool.doActionFor(topic, 'publish')
00341 
00342         # Previous events subtopic
00343         if 'previous' not in topic.objectIds():
00344             prev_events_title = 'Past Events'
00345             prev_events_desc = 'Events which have already happened.'
00346             if target_language is not None:
00347                 util = queryUtility(ITranslationDomain, 'plonefrontpage')
00348                 if util is not None:
00349                     prev_events_title = util.translate(u'prev-events-title',
00350                                            target_language=target_language,
00351                                            default='Past Events')
00352                     prev_events_desc = util.translate(u'prev-events-description',
00353                                           target_language=target_language,
00354                                           default='Events which have already happened.')
00355 
00356             _createObjectByType('Topic', topic, id='previous',
00357                                 title=prev_events_title,
00358                                 description=prev_events_desc)
00359             topic = topic.previous
00360             if language is not None:
00361                 topic.setLanguage(language)
00362             topic.setAcquireCriteria(True)
00363             topic.unmarkCreationFlag()
00364             sort_crit = topic.addCriterion('end','ATSortCriterion')
00365             sort_crit.setReversed(True)
00366             date_crit = topic.addCriterion('end','ATFriendlyDateCriteria')
00367             # Set date reference to now
00368             date_crit.setValue(0)
00369             # Only take events in the past
00370             date_crit.setDateRange('-') # This is irrelevant when the date is now
00371             date_crit.setOperation('less')
00372 
00373             if wftool.getInfoFor(topic, 'review_state') != 'published':
00374                 wftool.doActionFor(topic, 'publish')
00375 
00376         if 'Members' in existing:
00377             # configure Members folder (already added by the content import)
00378             members_title = 'Users'
00379             members_desc = "Container for users' home directories"
00380             if target_language is not None:
00381                 util = queryUtility(ITranslationDomain, 'plonefrontpage')
00382                 if util is not None:
00383                     members_title = util.translate(u'members-title',
00384                                            target_language=target_language,
00385                                            default='Users')
00386                     members_desc = util.translate(u'members-description',
00387                                           target_language=target_language,
00388                                           default="Container for users' home directories")
00389 
00390             members = getattr(p , 'Members')
00391             members.setTitle(members_title)
00392             members.setDescription(members_desc)
00393             members.unmarkCreationFlag()
00394             if language is not None:
00395                 members.setLanguage(language)
00396             members.reindexObject()
00397 
00398             if wftool.getInfoFor(members, 'review_state') != 'published':
00399                 wftool.doActionFor(members, 'publish')
00400 
00401             # add index_html to Members area
00402             if 'index_html' not in members.objectIds():
00403                 addPy = members.manage_addProduct['PythonScripts'].manage_addPythonScript
00404                 addPy('index_html')
00405                 index_html = getattr(members, 'index_html')
00406                 index_html.write(member_indexhtml)
00407                 index_html.ZPythonScript_setTitle('User Search')

Here is the call graph for this function:


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