def upgrade_actions_tool(tool): """2.0.x to 2.1.0 upgrade step handler """ logger = logging.getLogger('GenericSetup.upgrade') atool = getToolByName(tool, 'portal_actions') environ = SetupEnviron() environ._should_purge = False getMultiAdapter((atool, environ), IBody).body = _ACTIONS_XML logger.info("'interfaces' action added.")
def install(self,reinstall=False): """Install a set of products (which themselves may either use Install.py or GenericSetup extension profiles for their configuration) and then install a set of extension profiles. One of the extension profiles we install is that of this product. This works because an Install.py installation script (such as this one) takes precedence over extension profiles for the same product in portal_quickinstaller. We do this because it is not possible to install other products during the execution of an extension profile (i.e. we cannot do this during the importVarious step for this profile). """ portal_quickinstaller = getToolByName(self, 'portal_quickinstaller') portal_setup = getToolByName(self, 'portal_setup') from Products.GenericSetup.context import Logger,SetupEnviron import logging obj = SetupEnviron() out = StringIO() logger = obj.getLogger("cenditel.ppm") outch = logging.StreamHandler(out) logger.addHandler(outch) #import pdb; pdb.set_trace() if reinstall: for product in PRODUCT_DEPENDENCIES: if not portal_quickinstaller.isProductInstalled(product): portal_quickinstaller.installProduct(product) transaction.savepoint() for product in PRODUCT_DEPENDENCIES: #import pdb; pdb.set_trace() if portal_quickinstaller.isProductInstalled(product): portal_quickinstaller.reinstallProducts([product]) transaction.savepoint() elif not portal_quickinstaller.isProductInstalled(product): portal_quickinstaller.installProduct(product) transaction.savepoint() else: for product in PRODUCT_DEPENDENCIES: if not portal_quickinstaller.isProductInstalled(product): logger.info("Installing missing product: %s" % product) portal_quickinstaller.installProduct(product) transaction.savepoint() for extension_id in EXTENSION_PROFILES: portal_setup.runAllImportStepsFromProfile('profile-%s' % extension_id, purge_old=False) product_name = extension_id.split(':')[0] portal_quickinstaller.notifyInstalled(product_name) transaction.savepoint()
def upgrade_actions_tool(tool): """2.2.x to 2.3.0 upgrade step handler """ logger = logging.getLogger('GenericSetup.upgrade') atool = getToolByName(tool, 'portal_actions') environ = SetupEnviron() environ._should_purge = False getMultiAdapter((atool, environ), IBody).body = _ACTIONS_PASSWORD_XML logger.info("'change_password' action added.") getMultiAdapter((atool, environ), IBody).body = _ACTIONS_REGISTER_XML logger.info("'members_register' action added.") getMultiAdapter((atool, environ), IBody).body = _ACTIONS_SYNDICATION_XML logger.info("'portal syndication settings' action added.")
def _get_importer(self, blacklist=set([])): reg = getToolByName(self.portal, 'portal_javascripts') importer = ResourceRegistryNodeAdapter(reg, SetupEnviron()) importer.resource_type = 'javascript' importer.registry = getUtility(IRegistry) importer.resource_blacklist = blacklist return importer
def importVarious(context): """Miscellanous steps import handle """ #VAMOS A PONERLA EN EL CONFIG USERNAME='******' username=USERNAME title='cenditel.ppm' # Ordinarily, GenericSetup handlers check for the existence of XML files. # Here, we are not parsing an XML file, but we use this text file as a # flag to check that we actually meant for this import step to be run. # The file is found in profiles/default. if context.readDataFile('cenditel.ppm.txt') is None: return portal = context.getSite() obj = SetupEnviron() logger = obj.getLogger("cenditel.ppm") MakeDefaultUser(context, username, title)
def upgrade_root_lookup_class(tool): """2.1 beta to 2.1.0 upgrade step handler """ logger = logging.getLogger('GenericSetup.upgrade') portal = aq_base(aq_parent(aq_inner(tool))) components = portal.getSiteManager() components.__parent__ = portal components.utilities.LookupClass = FiveVerifyingAdapterLookup components.utilities._createLookup() components.utilities.__parent__ = components logger.info('LookupClass replaced.') getMultiAdapter((components, SetupEnviron()), IBody).body = _XML logger.info('Utility registrations replaced.')
def upgrade_portal_types(tool): """2.2.x to 2.3.0 upgrade step handler """ logger = logging.getLogger('GenericSetup.upgrade') ttool = getToolByName(tool, 'portal_types') wtool = getToolByName(tool, 'portal_workflow') environ = SetupEnviron() environ._should_purge = False try: ttool['Home Folder'] except KeyError: getMultiAdapter((ttool, environ), IBody).body = _TTOOL_HOME_XML obj = ttool['Home Folder'] getMultiAdapter((obj, environ), IBody).body = _HOME_FOLDER_XML getMultiAdapter((wtool, environ), IBody).body = _WTOOL_HOME_XML logger.info("'Home Folder' type added.") try: ttool['Members Folder'] except KeyError: getMultiAdapter((ttool, environ), IBody).body = _TTOOL_MEMBERS_XML obj = ttool['Members Folder'] getMultiAdapter((obj, environ), IBody).body = _MEMBERS_FOLDER_XML getMultiAdapter((wtool, environ), IBody).body = _WTOOL_MEMBERS_XML logger.info("'Members Folder' type added.")
def add_root_site_manager(tool): """2.0.x to 2.1.0 upgrade step handler """ logger = logging.getLogger('GenericSetup.upgrade') portal = aq_base(aq_parent(aq_inner(tool))) next = find_next_sitemanager(portal) if next is None: next = base name = '/'.join(portal.getPhysicalPath()) components = PersistentComponents(name, (next, )) components.__parent__ = portal portal.setSiteManager(components) logger.info("Site manager '%s' added." % name) getMultiAdapter((components, SetupEnviron()), IBody).body = _XML logger.info('Utility registrations added.')
def upgrade_root_site_manager(tool): """2.0.x to 2.1.0 upgrade step handler """ logger = logging.getLogger('GenericSetup.upgrade') portal = aq_parent(aq_inner(tool)) try: setSite(portal) sm = portal.getSiteManager() if sm.utilities.LookupClass != FiveVerifyingAdapterLookup: sm.__parent__ = aq_base(portal) sm.utilities.LookupClass = FiveVerifyingAdapterLookup sm.utilities._createLookup() sm.utilities.__parent__ = sm logger.info('LookupClass replaced.') else: for tool_interface in _BAD_UTILITIES: try: iface = resolve(tool_interface) except ImportError: continue if sm.queryUtility(iface) is not None: sm.unregisterUtility(provided=iface) logger.info('Unregistered utility for %s' % tool_interface) for tool_id, tool_interface in _TOOL_UTILITIES: tool_obj = getToolByName(portal, tool_id, default=None) try: iface = resolve(tool_interface) except ImportError: continue if tool_obj is not None and sm.queryUtility(iface) is None: sm.registerUtility(tool_obj, iface) logger.info('Registered %s for interface %s' % (tool_id, tool_interface)) return except ComponentLookupError: next = find_next_sitemanager(portal) if next is None: next = base name = '/'.join(portal.getPhysicalPath()) sm = PersistentComponents(name, (next, )) sm.__parent__ = aq_base(portal) portal.setSiteManager(sm) logger.info("Site manager '%s' added." % name) getMultiAdapter((sm, SetupEnviron()), IBody).body = _COMPONENTS_XML logger.info('Utility registrations added.')
def test_resource_no_blacklist(self): # Ensure that blacklisted resources aren't imported reg = getToolByName(self.portal, 'portal_javascripts') importer = ResourceRegistryNodeAdapter(reg, SetupEnviron()) importer.resource_type = 'javascript' importer.registry = getUtility(IRegistry) importer.resource_blacklist = set() dom = parseString(""" <object> <javascript id="++resource++/bad_resource.js" enabled="true" /> </object> """) importer._importNode(dom.documentElement) resources = importer.registry.collectionOfInterface( IResourceRegistry, prefix="plone.resources" ) js_files = [x.js for x in resources.values()] self.assertTrue("++resource++/bad_resource.js" in js_files)
def install(self, reinstall=False): """Install a set of products (which themselves may either use Install.py or GenericSetup extension profiles for their configuration) and then install a set of extension profiles. One of the extension profiles we install is that of this product. This works because an Install.py installation script (such as this one) takes precedence over extension profiles for the same product in portal_quickinstaller. We do this because it is not possible to install other products during the execution of an extension profile (i.e. we cannot do this during the importVarious step for this profile). """ out = StringIO() from Products.GenericSetup.context import Logger,SetupEnviron import logging obj = SetupEnviron() logger = obj.getLogger("ubify.policy") outch = logging.StreamHandler(out) logger.addHandler(outch) #import pdb; pdb.set_trace() portal_quickinstaller = getToolByName(self, 'portal_quickinstaller') portal_setup = getToolByName(self, 'portal_setup') if reinstall: for product in PRODUCT_DEPENDENCIES: if not portal_quickinstaller.isProductInstalled(product): portal_quickinstaller.installProduct(product) transaction.savepoint() for product in PRODUCT_DEPENDENCIES: if portal_quickinstaller.isProductInstalled(product): portal_quickinstaller.reinstallProducts([product]) transaction.savepoint() elif not portal_quickinstaller.isProductInstalled(product): portal_quickinstaller.installProduct(product) transaction.savepoint() else: for product in PRODUCT_DEPENDENCIES: if not portal_quickinstaller.isProductInstalled(product): logger.info("Installing missing product: %s" % product) portal_quickinstaller.installProduct(product) transaction.savepoint() for extension_id in EXTENSION_PROFILES: portal_setup.runAllImportStepsFromProfile('profile-%s' % extension_id, purge_old=False) product_name = extension_id.split(':')[0] portal_quickinstaller.notifyInstalled(product_name) transaction.savepoint() #call one time installation here if reinstall is false portal = self if reinstall: for product in UNINSTALL_PRODUCTS: if portal_quickinstaller.isProductInstalled(product): try: from Products.CMFQuickInstallerTool.InstalledProduct import InstalledProduct prod=getattr(portal_quickinstaller,product) prod.uninstall(cascade=InstalledProduct.default_cascade, reinstall=False) logger.info("Uninstalled product successfully : %s" % (product,)) except AttributeError: pass transaction.savepoint() from ubify.policy.migration.onetimeinstall import disableGlobalAdds,reorder_contenttyperegistry reorder_contenttyperegistry(portal,logger) disableGlobalAdds(portal,logger) else: from ubify.policy.migration.onetimeinstall import assignStackerRelatedPortlet,setup_sitehome_portlets from ubify.policy.migration.onetimeinstall import disableGlobalAdds,disable_inlineEditing from ubify.policy.setuphandlers import addDefaultCategories from ubify.policy.migration.onetimeinstall import remove_navigationportlet,remove_calendarportlet from ubify.policy.migration.onetimeinstall import setchoosertype,configureRatings,add_custom_site_properties,add_custom_cynin_properties from ubify.policy.migration.onetimeinstall import enable_formats_fortextfield,assignCyninNavigation,reorder_contenttyperegistry add_custom_site_properties(portal,logger) add_custom_cynin_properties(portal,logger) reorder_contenttyperegistry(portal,logger) setchoosertype(portal,logger) addDefaultCategories(portal,logger) assignStackerRelatedPortlet(portal) disableGlobalAdds(portal,logger) setup_sitehome_portlets(portal,logger) # disable_inlineEditing(portal,logger) remove_navigationportlet(portal,logger) remove_calendarportlet(portal,logger) configureRatings(portal,logger) enable_formats_fortextfield(portal,logger) assignCyninNavigation(portal,logger) from ubify.policy.migration.onetimeinstall import updateWorkflowSecurity updateWorkflowSecurity(portal,logger) return out.getvalue()
def importVarious(context): """Miscellanous steps import handle """ # Ordinarily, GenericSetup handlers check for the existence of XML files. # Here, we are not parsing an XML file, but we use this text file as a # flag to check that we actually meant for this import step to be run. # The file is found in profiles/default. if context.readDataFile('ubify.policy_various.txt') is None: return portal = context.getSite() from Products.GenericSetup.context import Logger,SetupEnviron obj = SetupEnviron() logger = obj.getLogger("ubify.policy") replaceCatalog(portal) old_smtphost = disableMailHost(portal,logger)#<-- Do this first so that reinstallation will not fire any notifications if any oldmdh_smtphost = disableMaildropHost(portal,logger) configureSiteTitle(portal,logger) configureContentTypes(portal,logger) setup_folders(portal,logger) setVersionedTypes(portal,logger) setAbortVersioningOfLargeFiles(portal,logger) enable_wikitype(portal,logger) setupSiteTabs(context,logger) addGroups(context,logger) addUsers(context,logger) #creating new content root item at site root setupContentRoot(portal,logger) configureCMFNotification(portal,logger) addRolesToListOfAllowedRolesToAddKeywords(portal,logger) # modifyKupuResourceTypes(portal,logger) # configureKupuToolbar(portal,logger) # allowembedtag(portal,logger) # configureKupuStyles(portal,logger) add_placeful_workflow_policy(portal,logger) removeAnonymousAccessOnMembers(portal,logger) getViews(portal) addRecyleBinToUsePortalFactory(portal,logger) setRecycleBin(portal,logger) addDefaultViewsForPloneSite(portal,logger) renameDefaultEntries(portal,logger) migration_steps(portal,logger) startMigration(context,logger) #<-- Migration step need to be last step before enabling MailHost updateWorkflowSecurity(portal,logger) configureMailHost(portal,logger) configureMaildropHost(portal,logger) enableMaildropHost(portal,logger,oldmdh_smtphost) enableMailHost(portal,logger,old_smtphost) #<-- Do this last so that mail smtp host configured before reinstallation will be maintained.
def _getBody(self): sm = self.context.aq_inner.getSiteManager() return getMultiAdapter((sm, SetupEnviron()), IBody).body
def install(self, reinstall=False): """Install a set of products (which themselves may either use Install.py or GenericSetup extension profiles for their configuration) and then install a set of extension profiles. One of the extension profiles we install is that of this product. This works because an Install.py installation script (such as this one) takes precedence over extension profiles for the same product in portal_quickinstaller. We do this because it is not possible to install other products during the execution of an extension profile (i.e. we cannot do this during the importVarious step for this profile). """ out = StringIO() from Products.GenericSetup.context import Logger, SetupEnviron import logging obj = SetupEnviron() logger = obj.getLogger("ubify.policy") outch = logging.StreamHandler(out) logger.addHandler(outch) #import pdb; pdb.set_trace() portal_quickinstaller = getToolByName(self, 'portal_quickinstaller') portal_setup = getToolByName(self, 'portal_setup') if reinstall: for product in PRODUCT_DEPENDENCIES: if not portal_quickinstaller.isProductInstalled(product): portal_quickinstaller.installProduct(product) transaction.savepoint() for product in PRODUCT_DEPENDENCIES: if portal_quickinstaller.isProductInstalled(product): portal_quickinstaller.reinstallProducts([product]) transaction.savepoint() elif not portal_quickinstaller.isProductInstalled(product): portal_quickinstaller.installProduct(product) transaction.savepoint() else: for product in PRODUCT_DEPENDENCIES: if not portal_quickinstaller.isProductInstalled(product): logger.info("Installing missing product: %s" % product) portal_quickinstaller.installProduct(product) transaction.savepoint() for extension_id in EXTENSION_PROFILES: portal_setup.runAllImportStepsFromProfile('profile-%s' % extension_id, purge_old=False) product_name = extension_id.split(':')[0] portal_quickinstaller.notifyInstalled(product_name) transaction.savepoint() #call one time installation here if reinstall is false portal = self if reinstall: for product in UNINSTALL_PRODUCTS: if portal_quickinstaller.isProductInstalled(product): try: from Products.CMFQuickInstallerTool.InstalledProduct import InstalledProduct prod = getattr(portal_quickinstaller, product) prod.uninstall(cascade=InstalledProduct.default_cascade, reinstall=False) logger.info("Uninstalled product successfully : %s" % (product, )) except AttributeError: pass transaction.savepoint() from ubify.policy.migration.onetimeinstall import disableGlobalAdds, reorder_contenttyperegistry reorder_contenttyperegistry(portal, logger) disableGlobalAdds(portal, logger) else: from ubify.policy.migration.onetimeinstall import assignStackerRelatedPortlet, setup_sitehome_portlets from ubify.policy.migration.onetimeinstall import disableGlobalAdds, disable_inlineEditing from ubify.policy.setuphandlers import addDefaultCategories from ubify.policy.migration.onetimeinstall import remove_navigationportlet, remove_calendarportlet from ubify.policy.migration.onetimeinstall import setchoosertype, configureRatings, add_custom_site_properties, add_custom_cynin_properties from ubify.policy.migration.onetimeinstall import enable_formats_fortextfield, assignCyninNavigation, reorder_contenttyperegistry add_custom_site_properties(portal, logger) add_custom_cynin_properties(portal, logger) reorder_contenttyperegistry(portal, logger) setchoosertype(portal, logger) addDefaultCategories(portal, logger) assignStackerRelatedPortlet(portal) disableGlobalAdds(portal, logger) setup_sitehome_portlets(portal, logger) disable_inlineEditing(portal, logger) remove_navigationportlet(portal, logger) remove_calendarportlet(portal, logger) configureRatings(portal, logger) enable_formats_fortextfield(portal, logger) assignCyninNavigation(portal, logger) from ubify.policy.migration.onetimeinstall import updateWorkflowSecurity updateWorkflowSecurity(portal, logger) return out.getvalue()
def _setBody(self, value): sm = self.context.aq_inner.getSiteManager() getMultiAdapter((sm, SetupEnviron()), IBody).body = value
def importVarious(context): """Miscellanous steps import handle """ # Ordinarily, GenericSetup handlers check for the existence of XML files. # Here, we are not parsing an XML file, but we use this text file as a # flag to check that we actually meant for this import step to be run. # The file is found in profiles/default. if context.readDataFile('ubify.policy_various.txt') is None: return portal = context.getSite() from Products.GenericSetup.context import Logger, SetupEnviron obj = SetupEnviron() logger = obj.getLogger("ubify.policy") replaceCatalog(portal) old_smtphost = disableMailHost( portal, logger ) #<-- Do this first so that reinstallation will not fire any notifications if any oldmdh_smtphost = disableMaildropHost(portal, logger) configureSiteTitle(portal, logger) configureContentTypes(portal, logger) setup_folders(portal, logger) setVersionedTypes(portal, logger) setAbortVersioningOfLargeFiles(portal, logger) enable_wikitype(portal, logger) setupSiteTabs(context, logger) addGroups(context, logger) addUsers(context, logger) #creating new content root item at site root setupContentRoot(portal, logger) configureCMFNotification(portal, logger) addRolesToListOfAllowedRolesToAddKeywords(portal, logger) modifyKupuResourceTypes(portal, logger) configureKupuToolbar(portal, logger) allowembedtag(portal, logger) configureKupuStyles(portal, logger) add_placeful_workflow_policy(portal, logger) removeAnonymousAccessOnMembers(portal, logger) getViews(portal) addRecyleBinToUsePortalFactory(portal, logger) setRecycleBin(portal, logger) addDefaultViewsForPloneSite(portal, logger) renameDefaultEntries(portal, logger) migration_steps(portal, logger) startMigration( context, logger ) #<-- Migration step need to be last step before enabling MailHost updateWorkflowSecurity(portal, logger) configureMailHost(portal, logger) configureMaildropHost(portal, logger) enableMaildropHost(portal, logger, oldmdh_smtphost) enableMailHost( portal, logger, old_smtphost ) #<-- Do this last so that mail smtp host configured before reinstallation will be maintained.