def install(self): """Install STSample""" out = StringIO() print >> out, "Installing %s" % PROJECTNAME # Install types classes = listTypes(PROJECTNAME) installTypes(self, out, classes, PROJECTNAME) print >> out, "Installed types" # Migrate FTI, to make sure we get the necessary infrastructure for the # 'display' menu to work. migrated = migrateFTIs(self, product=PROJECTNAME) print >>out, "Switched to DynamicViewFTI: %s" % ', '.join(migrated) # Enable portal_factory factory = getToolByName(self, 'portal_factory') types = factory.getFactoryTypes().keys() for add_type in ('STSample',): if add_type not in types: types.append(add_type) factory.manage_setPortalFactoryTypes(listOfTypeIds = types) print >> out, "Added %s to portal_factory" % PROJECTNAME install_resources(self, out) return out.getvalue()
def install(self): out = StringIO() installTypes(self, out, listTypes(PROJECTNAME), PROJECTNAME) install_subskin(self, out, GLOBALS) if PRE_PLONE3: # Migrate FTI, to make sure we get the necessary infrastructure for the # 'display' menu to work. migrated = migrateFTIs(self, product=PROJECTNAME) print >>out, "Switched to DynamicViewFTI: %s" % ', '.join(migrated) # install slots slotpath='here/portlet_simpleportlet/macros/' # Enable portal_factory factory = getToolByName(self, 'portal_factory') types = factory.getFactoryTypes().keys() if 'Portlet' not in types: types.append('Portlet') factory.manage_setPortalFactoryTypes(listOfTypeIds = types) if 'TopicPortlet' not in types: types.append('TopicPortlet') factory.manage_setPortalFactoryTypes(listOfTypeIds = types) if 'RSSPortlet' not in types: types.append('RSSPortlet') factory.manage_setPortalFactoryTypes(listOfTypeIds = types) #create the tool instance portal = getToolByName(self, 'portal_url').getPortalObject() if not hasattr(self, 'portlet_manager'): addTool = portal.manage_addProduct['SimplePortlet'].manage_addTool addTool(type='SimplePortlet tool') at=getToolByName(self, 'portal_actions') if 'portlets' not in [action.id for action in at.listActions()]: at.addAction('portlets', 'Portlets', 'string: ${folder_url}/portlet_setup', 'python: portal.plone_utils.isDefaultPage(object) or object is folder', 'SimplePortlet: Manage Portlet Layout','object') try: if not slotpath + 'portlet_left' in portal.left_slots: portal.left_slots = list(portal.left_slots) + [slotpath+'portlet_left', ] if not slotpath + 'portlet_right' in portal.right_slots: portal.right_slots = list(portal.right_slots) + [slotpath+'portlet_right', ] except: pass # collect existing non-standard plone portlets additionalPortlets = extractExistingPortlets(self) # try to add them to the portlet_tool for p in additionalPortlets.keys(): self.portlet_manager.registerPortlet(p, additionalPortlets[p]) print >> out, "Successfully installed %s." % PROJECTNAME return out.getvalue()
def install(self): """Install COREBlog2: Install content types, skin layer, install the stylesheet, set up global properties, enable the portal factory and set up form controller actions for the widget actions """ out = StringIO() # Install tool id = COREBlog2Tool.id if not hasattr(aq_base(self), id): addTool = self.manage_addProduct['COREBlog2'].manage_addTool addTool(COREBlog2Tool.meta_type) print >>out, 'Installing COREBlog2 Tool' print >> out, "Installing COREBlog2" # Install types classes = listTypes(PROJECTNAME) installTypes(self, out, classes, PROJECTNAME) print >> out, "Installed types" # Install skin install_subskin(self, out, GLOBALS) print >> out, "Installed skin" # Migrate FTI, to make sure we get the necessary infrastructure for the # 'display' menu to work. try: migrated = migrateFTIs(self, product=PROJECTNAME) print >>out, "Switched to DynamicViewFTI: %s" % ', '.join(migrated) except: print >>out, "DynamicViewFTI might not works well. You use Plone 3.0 alpha ?" # Enable portal_factory factory = getToolByName(self, 'portal_factory') types = factory.getFactoryTypes().keys() for add_type in ['COREBlog2','COREBlogEntry','COREBlogCategory']: if add_type not in types: types.append(add_type) factory.manage_setPortalFactoryTypes(listOfTypeIds = types) print >> out, "Added COREBlog2 to portal_factory" #propsTool = getToolByName(self, 'portal_properties') #siteProperties = getattr(propsTool, 'site_properties') #navtreeProperties = getattr(propsTool, 'navtree_properties') # install enabled index for topic atcttool = getToolByName(self, 'portal_atct') atcttool.addIndex('getTags', 'Tag', 'Tag(Category)', True, ('ATListCriterion', )) return out.getvalue()
def install(self): """Install COREBlog2: Install content types, skin layer, install the stylesheet, set up global properties, enable the portal factory and set up form controller actions for the widget actions """ out = StringIO() # Install tool id = COREBlog2Tool.id if not hasattr(aq_base(self), id): addTool = self.manage_addProduct['COREBlog2'].manage_addTool addTool(COREBlog2Tool.meta_type) print >> out, 'Installing COREBlog2 Tool' print >> out, "Installing COREBlog2" # Install types classes = listTypes(PROJECTNAME) installTypes(self, out, classes, PROJECTNAME) print >> out, "Installed types" # Install skin install_subskin(self, out, GLOBALS) print >> out, "Installed skin" # Migrate FTI, to make sure we get the necessary infrastructure for the # 'display' menu to work. try: migrated = migrateFTIs(self, product=PROJECTNAME) print >> out, "Switched to DynamicViewFTI: %s" % ', '.join(migrated) except: print >> out, "DynamicViewFTI might not works well. You use Plone 3.0 alpha ?" # Enable portal_factory factory = getToolByName(self, 'portal_factory') types = factory.getFactoryTypes().keys() for add_type in ['COREBlog2', 'COREBlogEntry', 'COREBlogCategory']: if add_type not in types: types.append(add_type) factory.manage_setPortalFactoryTypes(listOfTypeIds=types) print >> out, "Added COREBlog2 to portal_factory" #propsTool = getToolByName(self, 'portal_properties') #siteProperties = getattr(propsTool, 'site_properties') #navtreeProperties = getattr(propsTool, 'navtree_properties') # install enabled index for topic atcttool = getToolByName(self, 'portal_atct') atcttool.addIndex('getTags', 'Tag', 'Tag(Category)', True, ('ATListCriterion', )) return out.getvalue()
def install(self): """Install PFGDataGrid""" ####################### # Both PloneFormGen and the target field provider are going to have to be installed # first. So, let's check. portal_skins = getToolByName(self, 'portal_skins') assert safe_hasattr(portal_skins, 'DataGridWidget'), "DataGridField must be installed prior to installing this product." assert safe_hasattr(portal_skins, 'PloneFormGen'), "PloneFormGen must be installed prior to installing this product." # Safe to proceed. classes = listTypes(PROJECTNAME) # get a list of types provided by this product # note that this trick will cause problems if the meta_type doesn't match class name myTypes = [item['name'] for item in classes] out = StringIO() print >> out, "Installing %s" % PROJECTNAME # boilerplate setup of DynamicViewFTI and factory installTypes(self, out, classes, PROJECTNAME) print >> out, "Installed types" migrated = migrateFTIs(self, product=PROJECTNAME) print >>out, "Switched to DynamicViewFTI: %s" % ', '.join(migrated) factory = getToolByName(self, 'portal_factory') types = factory.getFactoryTypes().keys() for add_type in myTypes: if add_type not in types: types.append(add_type) factory.manage_setPortalFactoryTypes(listOfTypeIds = types) print >> out, "Added %s to portal_factory" % ', '.join(myTypes) ####################### # form fields should not be visible to navigation or search. # they should have no workflow of their own. propsTool = getToolByName(self, 'portal_properties') siteProperties = getattr(propsTool, 'site_properties') navtreeProperties = getattr(propsTool, 'navtree_properties') # Add to types_not_searched typesNotSearched = list(siteProperties.getProperty('types_not_searched')) for f in myTypes: if f not in typesNotSearched: typesNotSearched.append(f) siteProperties.manage_changeProperties(types_not_searched = typesNotSearched) print >> out, "Added %ss to types_not_searched" % ', '.join(myTypes) # Add to types excluded from navigation typesNotListed = list(navtreeProperties.getProperty('metaTypesNotToList')) for f in myTypes: if f not in typesNotListed: typesNotListed.append(f) navtreeProperties.manage_changeProperties(metaTypesNotToList = typesNotListed) print >> out, "Added %s to metaTypesNotToList" % ', '.join(myTypes) # Set up the workflow: there should be none! wft = getToolByName(self, 'portal_workflow') wft.setChainForPortalTypes(myTypes, ()) print >> out, "Set up empty workflows for %s." % ', '.join(myTypes) ####################### # Here's the code specific to making this visible to PloneFormGen portal_types = getToolByName(self, 'portal_types') for typeName in ('FormFolder', 'FieldsetFolder'): ptType = portal_types.getTypeInfo(typeName) ffact = list(ptType.allowed_content_types) ffact += myTypes ptType.manage_changeProperties(allowed_content_types = ffact) print >> out, "Added %s to allowed_content_types for %s" % (', '.join(myTypes), typeName) # End PFG installation ####################### print >> out, "Done." return out.getvalue()
quickinstaller.installProduct(dependency) get_transaction().commit(1) classes = listTypes(PROJECTNAME) installTypes(self, out, classes, PROJECTNAME) install_subskin(self, out, GLOBALS) <dtml-if "[klass for klass in generator.getGeneratedClasses(package) if generator.getOption('migrate_dynamic_view_fti', klass, None)]"> # Migrate FTI, to make sure we get the necessary infrastructure for the # "display" menu to work. if HAS_DYNAMIC_VIEW_FTI: <dtml-in "[klass for klass in generator.getGeneratedClasses(package) if generator.getOption('migrate_dynamic_view_fti', klass, None)]"> <dtml-let klass="_['sequence-item']"> migrated = migrateFTIs(self, product=PROJECTNAME, fti_meta_type='<dtml-var "klass.getCleanName()">') print >>out, "Switched to DynamicViewFTI: %s" % ', '.join(migrated) </dtml-let> </dtml-in> </dtml-if> <dtml-let klasses="[klass for klass in generator.getGeneratedClasses(package) if generator.getOption('catalogmultiplex:white', klass, None) or generator.getOption('catalogmultiplex:black', klass, None)]"> <dtml-if "klasses"> # Configure CatalogMultiplex: # explicit add classes (meta_types) be indexed in catalogs (white) # or removed from indexing in a catalog (black) atool = getToolByName(self, ARCHETYPETOOLNAME) catalogmap = {} <dtml-in "klasses"> <dtml-let klass="_['sequence-item']">
def install(self): out = StringIO() installTypes(self, out, listTypes(PROJECTNAME), PROJECTNAME) install_subskin(self, out, GLOBALS) # Migrate FTI, to make sure we get the necessary infrastructure for the # 'display' menu to work. migrated = migrateFTIs(self, product=PROJECTNAME) print >>out, "Switched to DynamicViewFTI: %s" % ', '.join(migrated) # Enable portal_factory factory = getToolByName(self, 'portal_factory') types = factory.getFactoryTypes().keys() if 'TrackBack' not in types: types.append('TrackBack') factory.manage_setPortalFactoryTypes(listOfTypeIds = types) if 'BlogEntry' not in types: types.append('BlogEntry') factory.manage_setPortalFactoryTypes(listOfTypeIds = types) if 'BlogFolder' not in types: types.append('BlogFolder') factory.manage_setPortalFactoryTypes(listOfTypeIds = types) if 'Blog' not in types: types.append('Blog') factory.manage_setPortalFactoryTypes(listOfTypeIds = types) portal = getToolByName(self,'portal_url').getPortalObject() if not hasattr(self, 'simpleblog_tool'): addTool = portal.manage_addProduct['SimpleBlog'].manage_addTool addTool(type='SimpleBlog manager') # register the css # Install stylesheet # Make it work for the entire portal because the portlets can # be used everywhere portal_css = getToolByName(self, 'portal_css') portal_css.manage_addStylesheet(id = 'SimpleBlogCSS.css', expression = '', media = 'all', title = 'SimpleBlog styles', enabled = True) #register the folderish items in portal_properties/site_properties for folder-contents views etc site_props = getToolByName(self, 'portal_properties').site_properties use_folder_tabs = site_props.getProperty('use_folder_tabs') if not 'Blog' in use_folder_tabs: site_props._updateProperty('use_folder_tabs', tuple(use_folder_tabs) + ('Blog','BlogFolder')) use_folder_contents = site_props.getProperty('use_folder_contents') if not 'Blog' in use_folder_contents: site_props._updateProperty('use_folder_contents', tuple(use_folder_contents) + ('Blog','BlogFolder')) if ENTRY_IS_FOLDERISH: if not 'BlogEntry' in use_folder_tabs: site_props._updateProperty('use_folder_tabs', tuple(use_folder_tabs) + ('BlogEntry',)) if not 'BlogEntry' in use_folder_contents: site_props._updateProperty('use_folder_contents', tuple(use_folder_contents) + ('BlogEntry',)) #Make sure blog entries aren't shown in the navtree by default nav_props = getToolByName(self, 'portal_properties').navtree_properties metaTypesNotToList = nav_props.getProperty('metaTypesNotToList') if not 'BlogEntry' in metaTypesNotToList: nav_props._updateProperty('metaTypesNotToList', tuple(metaTypesNotToList) + ('BlogEntry',)) # Add to default_page_types # Allow people to have a Blog as the default page propsTool = getToolByName(self, 'portal_properties') siteProperties = getattr(propsTool, 'site_properties') defaultPageTypes = list(siteProperties.getProperty('default_page_types')) if 'Blog' not in defaultPageTypes: defaultPageTypes.append('Blog') siteProperties.manage_changeProperties(default_page_types = defaultPageTypes) if not portal.hasProperty('trackback_notification_email'): portal.manage_addProperty('trackback_notification_email', '', 'string') # discussion enabled by default for BlogEntries getToolByName(self, 'portal_types').BlogEntry.allow_discussion=1 # register 2.0 control panel try: cp=self.portal_controlpanel cp.addAction(id='SimpleBlogSetup', name='SimpleBlog Setup', action='string:${portal_url}/prefs_simpleblog_form', permission='Manage portal', category='Products', appId='SimpleBlog', imageUrl='simpleblog_icon.gif', description='Configure SimpleBlog global settings') except: pass # install the workflow from Products.SimpleBlog import SimpleBlogWorkflow, TrackbackWorkflow reload(SimpleBlogWorkflow) reload(TrackbackWorkflow) # Remove workflows for BlogEntry and BlogFolder wf_tool = getToolByName(self, 'portal_workflow') wf_tool.setChainForPortalTypes( ('Blog', 'BlogEntry','BlogFolder'), []) add_workflow(self, 'simpleblog_workflow', 'simpleblog_workflow (Workflow for Blog Entries)', ('BlogEntry',), out) add_workflow(self, 'trackback_workflow', 'trackback_workflow (TrackBack Workflow)', ('TrackBack',), out) wf_tool.setChainForPortalTypes(('Blog','BlogFolder'), 'folder_workflow') print >> out, "Successfully installed %s." % PROJECTNAME return out.getvalue()
def install(self): """Install STArticle: Install content types, skin layer, install the stylesheet, set up global properties, enable the portal factory and set up form controller actions for the widget actions """ out = StringIO() print >> out, "Installing STArticle" # Install types classes = listTypes(PROJECTNAME) installTypes(self, out, classes, PROJECTNAME) print >> out, "Installed types" # Install skin install_subskin(self, out, product_globals) print >> out, "Installed skin" # Migrate FTI, to make sure we get the necessary infrastructure for the # 'display' menu to work. migrated = migrateFTIs(self, product=PROJECTNAME) print >>out, "Switched to DynamicViewFTI: %s" % ', '.join(migrated) # Install stylesheet portal_css = getToolByName(self, 'portal_css') portal_css.manage_addStylesheet(id = 'starticle.css', expression = 'python:object.getTypeInfo().getId() == "STArticle"', media = 'all', title = 'STArticle styles', enabled = True) # Enable portal_factory factory = getToolByName(self, 'portal_factory') types = factory.getFactoryTypes().keys() if 'STArticle' not in types: types.append('STArticle') factory.manage_setPortalFactoryTypes(listOfTypeIds = types) print >> out, "Added STArticle to portal_factory" propsTool = getToolByName(self, 'portal_properties') siteProperties = getattr(propsTool, 'site_properties') navtreeProperties = getattr(propsTool, 'navtree_properties') # Remove from use_folder_tabs useFolderTabs = list(siteProperties.getProperty('use_folder_tabs')) if 'STArticle' in useFolderTabs: useFolderTabs.remove('STArticle') siteProperties.manage_changeProperties(use_folder_tabs = useFolderTabs) # Remove from typesLinkToFolderContentsInFC typesLinkToFolderContentsInFC = list(siteProperties.getProperty('typesLinkToFolderContentsInFC')) if 'STArticle' in typesLinkToFolderContentsInFC: typesLinkToFolderContentsInFC.remove('STArticle') siteProperties.manage_changeProperties(typesLinkToFolderContentsInFC = typesLinkToFolderContentsInFC) # Add to default_page_types defaultPageTypes = list(siteProperties.getProperty('default_page_types')) if 'STArticle' not in defaultPageTypes: defaultPageTypes.append('STArticle') siteProperties.manage_changeProperties(default_page_types = defaultPageTypes) # Add to parentMetaTypesNotToQuery parentMetaTypesNotToQuery = list(navtreeProperties.getProperty('parentMetaTypesNotToQuery')) if 'STArticle' not in parentMetaTypesNotToQuery: parentMetaTypesNotToQuery.append('STArticle') navtreeProperties.manage_changeProperties(parentMetaTypesNotToQuery = parentMetaTypesNotToQuery) # Set up form controller actions for the widgets to work registerAttachmentsFormControllerActions(self, contentType = 'STArticle', template = 'atct_edit') registerImagesFormControllerActions(self, contentType = 'STArticle', template = 'atct_edit') print >> out, "Added actions for the image and attachment controls to the atct_edit form controller." # Register form controller actions for LinguaPlone translate_item registerAttachmentsFormControllerActions(self, contentType = 'STArticle', template = 'translate_item') registerImagesFormControllerActions(self, contentType = 'STArticle', template = 'translate_item') print >> out, "Added actions for the image and attachment controls to the translate_item form controller." # Set up the workflow for the widget types setupFileAttachmentWorkflow(self) setupImageAttachmentWorkflow(self) print >> out, "Set up FileAttachment and ImageAttachment workflows." # Make the widget types use the /view action when linked to setupFileAttachmentView(self) setupImageAttachmentView(self) print >> out, "Set up FileAttachment and ImageAttachment to use /view." # Add the FileAttachment and ImageAttachment types to types_not_searched # (this is configurable via the Search settings control panel) typesNotSearched = list(siteProperties.getProperty('types_not_searched')) if 'FileAttachment' not in typesNotSearched: typesNotSearched.append('FileAttachment') if 'ImageAttachment' not in typesNotSearched: typesNotSearched.append('ImageAttachment') siteProperties.manage_changeProperties(types_not_searched = typesNotSearched) print >> out, "Added FileAttachment and ImageAttachment to types_not_searched" # Add FileAttachment and ImageAttachment to kupu's linkable and media # types kupuTool = getToolByName(self, 'kupu_library_tool') linkable = list(kupuTool.getPortalTypesForResourceType('linkable')) mediaobject = list(kupuTool.getPortalTypesForResourceType('mediaobject')) if 'FileAttachment' not in linkable: linkable.append('FileAttachment') if 'ImageAttachment' not in linkable: linkable.append('ImageAttachment') if 'STArticle' not in linkable: linkable.append('STArticle') if 'ImageAttachment' not in mediaobject: mediaobject.append('ImageAttachment') # kupu_library_tool has an idiotic interface, basically written purely to # work with its configuration page. :-( kupuTool.updateResourceTypes(({'resource_type' : 'linkable', 'old_type' : 'linkable', 'portal_types' : linkable}, {'resource_type' : 'mediaobject', 'old_type' : 'mediaobject', 'portal_types' : mediaobject},)) print >> out, "Added FileAttachment and ImageAttachment to kupu's linkable and mediaobject types" return out.getvalue()