def initialize(context): import Products.PloneSurvey.content ADD_CONTENT_PERMISSIONS = {} types = listTypes(PROJECTNAME) for aType in types: if aType['portal_type'] in ['Survey',]: ADD_CONTENT_PERMISSIONS[aType['portal_type']] = addSurvey else: ADD_CONTENT_PERMISSIONS[aType['portal_type']] = AddPortalContent content_types, constructors, ftis = process_types( listTypes(PROJECTNAME), PROJECTNAME) allTypes = zip(content_types, constructors) for aType, constructor in allTypes: kind = "%s: %s" % (PROJECTNAME, aType.portal_type) ContentInit( kind, content_types = (aType,), permission = ADD_CONTENT_PERMISSIONS[aType.portal_type], extra_constructors = (constructor,), fti = ftis, ).initialize(context)
def initialize(context): import Products.PloneSurvey.content ADD_CONTENT_PERMISSIONS = {} types = listTypes(PROJECTNAME) for aType in types: if aType['portal_type'] in [ 'Survey', ]: ADD_CONTENT_PERMISSIONS[aType['portal_type']] = addSurvey else: ADD_CONTENT_PERMISSIONS[aType['portal_type']] = AddPortalContent content_types, constructors, ftis = process_types(listTypes(PROJECTNAME), PROJECTNAME) allTypes = zip(content_types, constructors) for aType, constructor in allTypes: kind = "%s: %s" % (PROJECTNAME, aType.portal_type) ContentInit( kind, content_types=(aType, ), permission=ADD_CONTENT_PERMISSIONS[aType.portal_type], extra_constructors=(constructor, ), fti=ftis, ).initialize(context)
def initialize(context): """load up content types""" from Products.CMFCore import utils as cmf_utils #app = context._ProductContext__app #patch_listDefaultTypeInformation(app) from ironicwiki import IronicWiki try: from wickeddoc import WickedDoc except ImportError: # no ATCT pass types = atapi.listTypes(PROJECTNAME) content_types, constructors, ftis = atapi.process_types( types, PROJECTNAME) permissions = {} types = atapi.listTypes(PROJECTNAME) for atype in types: permission = "%s: Add %s" % (PROJECTNAME, atype['portal_type']) permissions[atype['portal_type']] = permission # Assign default roles setDefaultRoles(permission, ('Manager', 'Owner')) allTypes = zip(content_types, constructors) for atype, constructor in allTypes: kind = "%s: %s" % (PROJECTNAME, atype.archetype_name) cmf_utils.ContentInit( kind, content_types = (atype,), permission = permissions[atype.portal_type], extra_constructors = (constructor,), fti = ftis, ).initialize(context)
def install(self): out = StringIO() self._addRole("Procurement") self._addRole("Finance") for account in config.accounts.keys(): self.acl_users.userFolderAddGroup(utils.getGroupFromAccount(account), ()) installTypes(self, out, atapi.listTypes(config.PROJECTNAME), config.PROJECTNAME) install_subskin(self, out, config.GLOBALS) wf_tool = getToolByName(self, "portal_workflow") wf_tool.setChainForPortalTypes( [t['portal_type'] for t in atapi.listTypes(config.PROJECTNAME)], "alphaflow_fake") alf = getToolByName(self, 'workflow_manager') id = "procurement" if id in alf.processes.objectIds(): IProcessWriteContainer(alf.processes).remove(id) wf_dir = os.path.abspath( os.path.join( os.path.split(config.GLOBALS['__file__'])[0], "workflows")) importer = zope.component.getUtility(IWorkflowImporter, name='xml') version = importer(file(os.path.join(wf_dir, "simple.alf"))) process = IProcessWriteContainer(alf.processes).add(id, Process(id)) process.editable(version) process.update()
def install(self): out = StringIO() install_dependencies(self, out) # ######################################## """ACV OJO 20101027 To fix error when installing product through the test machinery. """ someTypes = listTypes(PROJECTNAME) for aType in someTypes: aKlass = aType.get('klass', None) if not (aKlass == None): aFTIMetaType = getattr(aKlass, '_at_fti_meta_type', None) if not (aFTIMetaType == 'Factory-based Type Information with dynamic views'): aKlass._at_fti_meta_type = 'Factory-based Type Information with dynamic views' """ACV OJO 20101027 To fix error when installing product through the test machinery. """ # ######################################## installTypes(self, out, listTypes(PROJECTNAME), PROJECTNAME) install_subskin(self, out, GLOBALS) install_tools(self, out) print >> out, utils.installConfiglets(self, CONFIGLETS) print >> out, "Successfully installed %s." % PROJECTNAME return out.getvalue()
def initialize(context): # install ATSE Tool import SchemaEditorTool import ATSETemplateTool if INSTALL_DEMO_TYPES: import examples.content content_types, constructors, ftis = process_types(listTypes(PROJECT_NAME), PROJECT_NAME) Products.CMFCore.utils.ContentInit( '%s Content' % PKG_NAME, content_types = content_types, permission = AddPortalContent, extra_constructors = constructors, fti = ftis, ).initialize(context) tools = (SchemaEditorTool.SchemaEditorTool, ATSETemplateTool.ATSETemplateTool ) Products.CMFCore.utils.ToolInit(meta_type=SchemaEditorTool.SchemaEditorTool.meta_type, tools=tools, icon='tool.jpg', ).initialize(context) Products.CMFCore.utils.ToolInit(meta_type=ATSETemplateTool.ATSETemplateTool.meta_type, tools=tools, icon='tool.jpg', ).initialize(context)
def migrateTypeFieldSchema(self): """Migrate typeField id 'type' to new (less overloaded) id 'publication_type' """ ct = getToolByName(self.site, "portal_catalog") bibtool = getToolByName(self.site, "portal_bibliography") # detect reference_types that contain the typeField ReferenceClasses_with_typeField = [ t["klass"] for t in listTypes() if (t["meta_type"] in bibtool.getReferenceTypes()) and ("publication_type" in [field.getName() for field in t["schema"].fields()]) ] ReferenceTypes_with_typeField = tuple([klass.meta_type for klass in ReferenceClasses_with_typeField]) brains = ct(meta_type=ReferenceTypes_with_typeField, Language="all") for brain in brains: bibref_item = brain.getObject() # this one is the old typeField value old_typeField_value = copy.deepcopy(getattr(bibref_item, "type", False)) # this one the new typeField with id 'publication_type' new_typeField = bibref_item.Schema().get("publication_type", None) # if there is no formerly set typeField value, just do the schema update if new_typeField and (type(old_typeField_value) == type(bibref_item.schema)): bibref_item._updateSchema() try: print >> self.out, u" Only simple schema update needed for ObjectId %s: typeField value='%s'" % ( brain.getId, bibref_item.getPublication_type(), ) except UnicodeDecodeError: print >> self.out, u" Only simple schema update needed for ObjectId %s: typeField value='%s'" % ( brain.getId, "<HIDDEN: value contains non-ASCII characters>", ) # but if there is an old 'type' attribute in the bibref_item object, update the new typeField with its value # to avoid mismatch with the BaseObject's type definition (alias for schema) check for a unicode value in typeField elif new_typeField and (type(old_typeField_value) == type(u"")): delattr(bibref_item, "type") bibref_item._updateSchema() bibref_item.edit(publication_type=old_typeField_value) try: print >> self.out, u" Migrating typeField of ObjectId %s: value='%s'" % ( brain.getId, bibref_item.getPublication_type(), ) except UnicodeDecodeError: print >> self.out, u" Migrating typeField of ObjectId %s: value='%s'" % ( brain.getId, "<HIDDEN: value contains non-ASCII characters>", ) else: print >> self.out, u" typeField schema update for ObjectId: %s failed." % bibref_item.getId() print >> self.out
def initialize(context): """Initializer called when used as a Zope 2 product.""" import ubify.recyclebin.content from Products.ATContentTypes.permission import permissions content_types, constructors, ftis = process_types(listTypes(PROJECTNAME), PROJECTNAME) allTypes = zip(content_types, constructors) for atype, constructor in allTypes: kind = "%s: %s" % (PROJECTNAME, atype.archetype_name) if atype.portal_type not in TYPES_NEW: ContentInit( kind, content_types=(atype, ), permission=permissions[atype.portal_type], extra_constructors=(constructor, ), ).initialize(context) else: ContentInit( kind, content_types=(atype, ), permission=DEFAULT_ADD_CONTENT_PERMISSION, extra_constructors=(constructor, ), ).initialize(context)
def initialize(context): """ initialization ... """ # initialize AT content types. import content content # make pyflakes happy content_types, constructors, ftis = process_types(listTypes(PROJECTNAME), PROJECTNAME) ContentInit( PROJECTNAME + ' Content', content_types=content_types, permission=ADD_CONTENT_PERMISSION, extra_constructors=constructors, fti=ftis, ).initialize(context) # register PAS plugin class. context.registerClass(ssouser.SsouserPlugins, constructors=( ssouser.manage_addSsouserPluginsForm, ssouser.manage_addSsouserPlugins, ), visibility=None) context.registerClass(proxy.ProxyMultiPlugins, constructors=( proxy.manage_addProxyMultiPluginsForm, proxy.manage_addProxyMultiPlugins, ), visibility=None)
def initialize(context): listOfTypes = listTypes(PROJECTNAME) content_types, constructors, ftis = process_types(listOfTypes, PROJECTNAME) ContentInit(PROJECTNAME + ' Content', content_types = content_types, permission = PlonePopoll_addPermission, extra_constructors = constructors, fti = ftis, ).initialize(context) ToolInit('%s Tool' % PROJECTNAME, tools = (PlonePopollTool,), icon = 'tool.gif', ).initialize(context) # This has to be improved so that only PlonePopollManager objects can hold PlonePopollBackends # and PlonePopollBackends can be derived. context.registerClass( PlonePopollZODBBackend, permission=view_management_screens, constructors=(manage_addPlonePopollZODBBackend,), visibility=None, icon='www/PlonePopollBackend.gif', ) context.registerClass( PlonePopollZSQLBackend, permission=view_management_screens, constructors=(manage_addPlonePopollZSQLBackend,), visibility=None, icon='www/PlonePopollBackend.gif', )
def initialize(context): import MoneyField import FixedPointField import MoneyWidget # As time goes by, more things will move from Python into the # profile. profile_desc = "Extra setup stuff for FinanceFields." profile_registry.registerProfile('default', 'FinanceFields', profile_desc, 'profiles/default', 'FinanceFields', EXTENSION, for_=IPloneSiteRoot, ) content_types, constructors, ftis = process_types( listTypes(PROJECTNAME), PROJECTNAME) ContentInit( PROJECTNAME + ' Content', content_types = content_types, permission = ADD_CONTENT_PERMISSION, extra_constructors = constructors, fti = ftis, ).initialize(context)
def gen_class(klass, schema=None): """generats and registers the klass """ if schema is not None: klass.schema = schema.copy() registerType(klass, 'AttachmentFieldTest') content_types, constructors, ftis = process_types(listTypes(), PKG_NAME)
def initialize(context): ##Import Types here to register them import Products.Ploneboard.content # If we put this import line to the top of module then # utils will magically point to Ploneboard.utils from Products.CMFCore import utils utils.ToolInit('Ploneboard Tool', tools=(PloneboardTool, ), icon='tool.gif').initialize(context) content_types, constructors, ftis = process_types(listTypes(PROJECTNAME), PROJECTNAME) # Assign an own permission to all content types # Heavily based on Bricolite's code from Ben Saller import permissions as perms allTypes = zip(content_types, constructors) for atype, constructor in allTypes: kind = "%s: %s" % (PROJECTNAME, atype.archetype_name) utils.ContentInit( kind, content_types=(atype, ), # Add permissions look like perms.Add{meta_type} permission=getattr(perms, 'Add%s' % atype.meta_type), extra_constructors=(constructor, ), fti=ftis, ).initialize(context) from AccessControl import allow_class from batch import Batch allow_class(Batch) this_module.Batch = Batch
def importVarious(context): """ Final jazkarta.pfg.jazshop import steps. """ # Only run step if a flag file is present (e.g. not an extension profile) if context.readDataFile('pfgjazshop-various.txt') is None: return site = context.getSite() ####################### # Both PloneFormGen and the target field provider are going to have # to be installed first. So, let's check. portal_skins = getToolByName(site, 'portal_skins') assert safe_hasattr( portal_skins, 'PloneFormGen' ), "PloneFormGen must be installed prior to installing this product." ####################### # Here's the code specific to making this visible to PloneFormGen classes = listTypes(config.PROJECTNAME) myTypes = [item['name'] for item in classes] portal_types = getToolByName(site, '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)
def initialize(context): install_types = DEBUG or \ os.environ.get(INSTALL_EXAMPLE_TYPES_ENVIRONMENT_VARIABLE) if install_types: # Import example types from Products.FileSystemStorage.examples import FSSItem content_types, constructors, ftis = process_types(listTypes(PROJECTNAME), PROJECTNAME) ContentInit('%s Content' % PROJECTNAME, content_types = content_types, permission = CMFCorePermissions.AddPortalContent, extra_constructors = constructors, fti = ftis, ).initialize(context) # Import tool from Products.FileSystemStorage.FSSTool import FSSTool ToolInit( '%s Tool' % PROJECTNAME, tools=(FSSTool,), product_name=PROJECTNAME, icon='tool.gif').initialize(context)
def initialize(context): ##Import Types here to register them from Products.PloneTemplates.content import Template content_types, constructors, ftis = process_types(listTypes(PROJECTNAME), PROJECTNAME) from Products.PloneTemplates.Permissions import permissions allTypes = zip(content_types, constructors) wireAddPermissions() for atype, constructor in allTypes: kind = "%s: %s" % (PROJECTNAME, atype.archetype_name) ContentInit( kind, content_types=(atype, ), permission=permissions[atype.portal_type], extra_constructors=(constructor, ), fti=ftis, ).initialize(context) from Products.PloneTemplates.TemplateTool import PloneTemplatesTool ToolInit( 'PloneTemplates tool', tools=(PloneTemplatesTool, ), icon='tool.gif', ).initialize(context) # patch types import Products.PloneTemplates.PatchSchemas
def initialize(context): """initialization method """ # generate the content types, constructors, and FTIs content_types, constructors, ftis = process_types(listTypes(PROJECTNAME), PROJECTNAME) # instatiates an object of the type ContentInit (from the CMFCore) and register the types in the CMF # or permission = DEFAULT_ADD_CONTENT_PERMISSION, utils.ContentInit( PROJECTNAME + ' Content', content_types=content_types, permission=ADD_CONTENT_PERMISSION, extra_constructors=constructors, fti=ftis, ).initialize(context) if HAS_GENERICSETUP: profile_registry.registerProfile(PROJECTNAME, PROJECTNAME, 'Extension profile for default setup', 'profiles/default', PROJECTNAME, EXTENSION, for_=IPloneSiteRoot)
def initialize(context): listOfTypes = listTypes(PROJECTNAME) content_types, constructors, ftis = process_types(listOfTypes, PROJECTNAME) ContentInit( PROJECTNAME + ' Content', content_types=content_types, permission=PlonePopoll_addPermission, extra_constructors=constructors, fti=ftis, ).initialize(context) ToolInit( '%s Tool' % PROJECTNAME, tools=(PlonePopollTool, ), icon='tool.gif', ).initialize(context) # This has to be improved so that only PlonePopollManager objects can hold PlonePopollBackends # and PlonePopollBackends can be derived. context.registerClass( PlonePopollZODBBackend, permission=view_management_screens, constructors=(manage_addPlonePopollZODBBackend, ), visibility=None, icon='www/PlonePopollBackend.gif', ) context.registerClass( PlonePopollZSQLBackend, permission=view_management_screens, constructors=(manage_addPlonePopollZSQLBackend, ), visibility=None, icon='www/PlonePopollBackend.gif', )
def initialize(context): import content ########## # Add our content types # A little different from the average Archetype product # due to the need to individualize some add permissions. # # This approach borrowed from ATContentTypes # listOfTypes = listTypes(PROJECTNAME) content_types, constructors, ftis = process_types( listOfTypes, PROJECTNAME) allTypes = zip(content_types, constructors) for atype, constructor in allTypes: kind = "%s: %s" % (PROJECTNAME, atype.archetype_name) if atype.portal_type == 'SalesforcePFGAdapter': permission = SFA_ADD_CONTENT_PERMISSION else: permission = ADD_CONTENT_PERMISSION utils.ContentInit( kind, content_types = (atype,), permission = permission, extra_constructors = (constructor,), fti = ftis, ).initialize(context) ModuleSecurityInfo('Products.PloneFormGen').declarePublic('SalesforcePFGAdapterMessageFactory') ModuleSecurityInfo('Products.PloneFormGen').declarePublic('HAS_PLONE25')
def initialize(context): from Products.Extropy import content content_types, constructors, ftis = process_types(listTypes(config.PROJECTNAME), config.PROJECTNAME) ContentInit( config.PROJECTNAME + " Content", content_types=content_types, permission=config.ADD_CONTENT_PERMISSION, extra_constructors=constructors, ).initialize(context) TOOLS = (tools.ExtropyTimeTrackerTool.ExtropyTimeTrackerTool, tools.ExtropyTrackingTool.ExtropyTrackingTool) ToolInit(config.PROJECTNAME + " Tool", tools=TOOLS, icon="tool.gif").initialize(context) import patches allow_module("Products.Extropy.odict") from Products.Extropy.odict import OrderedDict allow_class(OrderedDict) from Products.CMFPlone import i18nl10n i18nl10n.setDefaultDateFormat(("en",), u"yyyy-MM-dd") i18nl10n.setDefaultTimeFormat(("en",), u"HH:mm:ss")
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, reinstall=False): out = StringIO() out.write( 'CMFContentPanels installation tool\n') portal = getToolByName(self, 'portal_url').getPortalObject() setup_tool = getToolByName(portal, 'portal_setup') if PLONE_VERSION >= 3: setup_tool.runAllImportStepsFromProfile( "profile-Products.CMFContentPanels:default", purge_old=False) else: factory_tool = getToolByName(self,'portal_factory') factory_types=[ "ContentPanels", ] + factory_tool.getFactoryTypes().keys() factory_tool.manage_setPortalFactoryTypes(listOfTypeIds=factory_types) installTypes(self, out, listTypes(PROJECTNAME), PROJECTNAME) install_subskin(self, out, GLOBALS) if not hasattr(portal, 'portal_contentpanels'): portal._setObject( 'portal_contentpanels', ContentPanelsTool() ) out.write('Added ConentPanels Tool\n') p_cp=getToolByName(self, 'portal_contentpanels') p_cp.manage_installAllViewlets() install_RSSCache(portal, out) install_default_page(portal, out) addViewMethods(portal, out) return out.getvalue()
def importVarious(context): """ Final PFGDataGrid import steps. """ # Only run step if a flag file is present (e.g. not an extension profile) if context.readDataFile('pfgdatagrid-various.txt') is None: return site = context.getSite() ####################### # Both PloneFormGen and the target field provider are going to have # to be installed first. So, let's check. portal_skins = getToolByName(site, '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." ####################### # Here's the code specific to making this visible to PloneFormGen classes = listTypes(config.PROJECTNAME) myTypes = [item['name'] for item in classes] portal_types = getToolByName(site, '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)
def afterSetUp(self): out = StringIO() installTypes(self.portal, out, listTypes(PROJECTNAME), PROJECTNAME) self.types = ('ArchAddOnExample', ) self.setRoles(('Manager', )) self.portal.invokeFactory('ArchAddOnExample', 'aao') self.aao = self.portal.aao
def initialize(context): import Warenkorb import SimpleProduct import DefaultProduct # Register skin directory DirectoryView.registerDirectory("skins", globals()) content_types, constructors, ftis = process_types(listTypes(PROJECTNAME), PROJECTNAME) utils.ContentInit( PROJECTNAME + " Warenkorb", content_types=content_types, permission=ADD_CONTENT_PERMISSION, extra_constructors=constructors, fti=ftis, ).initialize(context) utils.ContentInit( PROJECTNAME + " Simple Product", content_types=content_types, permission=ADD_CONTENT_PERMISSION, extra_constructors=constructors, fti=ftis, ).initialize(context) utils.ContentInit( PROJECTNAME + " Default Product", content_types=content_types, permission=ADD_CONTENT_PERMISSION, extra_constructors=constructors, fti=ftis, ).initialize(context)
def initialize(): # the permission dict for all content types in this project. # What we are trying to do here is adding a "Add" permission for # each content type, and assigning default roles for this # permission to 'Manager' and 'Owner'. # We do NOT have to do this. We are free to add whatever # permission with whatever name (Of course, with some convention # on the name, it is much easier to management). permissions = {} # get all content types within this project. types = atapi.listTypes(config.PROJECTNAME) for aType in types: permission = '%s: Add %s' % (config.PROJECTNAME, aType['portal_type']) permissions[aType['portal_type']] = permission # the setDefaultRoles method will also add this new permission # to the Plone site. CMFCorePermissions.setDefaultRoles(permission, ('Manager', 'Owner')) return permissions
def initialize(context): # import at initialize: this let a chance to 3rd party products to change # config before deciding to patch import patches # used by test framework if config.INSTALL_EXAMPLES: import examples # Import types listOfTypes = listTypes(PROJECTNAME) content_types, constructors, ftis = process_types(listOfTypes, PROJECTNAME) ContentInit( '%s Content' % PROJECTNAME, content_types=content_types, permission=CMFCorePermissions.AddPortalContent, extra_constructors=constructors, fti=ftis, ).initialize(context) # Import tool ToolInit('%s Tool' % PROJECTNAME, tools=(PloneGlossaryTool, ), icon='tool.gif').initialize(context)
def install(self): out = StringIO() # Install types type_info = listTypes(PROJECTNAME) installTypes(self, out, type_info, PROJECTNAME) # Install tools add_tool = self.manage_addProduct[PROJECTNAME].manage_addTool if not self.objectIds(spec=FSSTool.meta_type): add_tool(FSSTool.meta_type) # Install skin install_subskin(self, out, GLOBALS) # Install configlet cp_tool = getToolByName(self, 'portal_controlpanel') try: cp_tool.registerConfiglet(**fss_prefs_configlet) except: pass # Install modifier install_modifier(self, out) out.write('Installation completed.\n') return out.getvalue()
def initialize(context): # import at initialize: this let a chance to 3rd party products to change # config before deciding to patch from Products.PloneGlossary import patches patches # pyflakes from Products.PloneGlossary.permissions import add_permissions # used by test framework if 'ZOPETESTCASE' in os.environ: import examples examples # pyflakes # Import types listOfTypes = listTypes(PROJECTNAME) content_types, constructors, ftis = process_types(listOfTypes, PROJECTNAME) for content_type, constructor in zip(content_types, constructors): kind = "%s: %s" % (PROJECTNAME, content_type.__name__) ContentInit( kind, content_types=(content_type, ), permission=add_permissions[content_type.__name__], extra_constructors=(constructor, ), fti=ftis, ).initialize(context) # Import tool ToolInit( '%s Tool' % PROJECTNAME, tools=(PloneGlossaryTool,), icon='tool.gif').initialize(context)
def install(self, reinstall=False): out = StringIO() utils.installDependencies(self, out) installTypes(self, out, listTypes(config.PROJECT_NAME), config.PROJECT_NAME, refresh_references=0) install_subskin(self, out, config.GLOBALS) utils.setupWorkflows(self, out) utils.setupCacheTool(self, out) utils.setupSquidTool(self, out) utils.setupPortalFactory(self, out) utils.setupFolderViews(self, out) utils.setupSiteProperties(self, out) utils.setupConfiglet(self, out) # clean up old cache policy and migrate changed schemas if reinstall: policy_utils.updateOldCachePolicy(self, out) utils.updateSchemas(self, out) # add new cache policies policy_utils.addCachePolicies(self, out) out.write("Successfully installed %s." % config.PROJECT_NAME) return out.getvalue()
def initialize(context): # Importing the content types allows for their registration # with the Archetypes runtime from Products.sampleremember import content # Ask Archetypes to handback all the type information needed # to make the CMF happy. types = atapi.listTypes(config.PROJECT_NAME) content_types, constructors, ftis = \ atapi.process_types(types, config.PROJECT_NAME) # We register each type with an add permission that is set # in permissions.py. By default, each content type has its # own permission, but this behavior can be easily overridden. permissions = initialize_permissions() allTypes = zip(content_types, constructors) for atype, constructor in allTypes: kind = "%s: %s" % (config.PROJECT_NAME, atype.archetype_name) cmf_utils.ContentInit( kind, content_types = (atype,), permission = permissions[atype.portal_type], extra_constructors = (constructor,), fti = ftis, ).initialize(context) profile_registry.registerProfile( 'default', 'sampleremember', "Installs sampleremember.", 'profiles/default', 'sampleremember', EXTENSION, for_=IPloneSiteRoot,)
def initialize(context): ##Import Types here to register them from content import Portlet from content import TopicPortlet if HAS_CMFSIN: from content import CMFSinPortlet content_types, constructors, ftis = process_types( listTypes(PROJECTNAME), PROJECTNAME) utils.ContentInit( PROJECTNAME + ' Content', content_types = content_types, permission = ADD_CONTENTS_PERMISSION, extra_constructors = constructors, fti = ftis, ).initialize(context) from SimplePortletTool import SimplePortletTool utils.ToolInit( 'SimplePortlet tool', tools=(SimplePortletTool,), icon='tool.gif', ).initialize(context)
def test_install(self): cpm = self.portal.caching_policy_manager cpm.addPolicy('foo', 'python:0', '', 1, 1, 0, 1, 'foo', '') original_class = cpm.__class__ installed_types = [typeinfo['name'] for typeinfo in listTypes(PROJECT_NAME)] # before installation the new types are not in the types factory portal_factory = getToolByName(self, 'portal_factory') self.assertEqual(set(installed_types).issubset(set(portal_factory.getFactoryTypes())), False) self.portal.portal_quickinstaller.installProducts(['CacheSetup']) self.portal.portal_quickinstaller.installProducts(['CacheSetup']) # now the new types are in the types factory self.assertEqual(set(installed_types).issubset(set(portal_factory.getFactoryTypes())), True) cpm = self.portal.caching_policy_manager self.assertNotEqual(cpm.__class__, original_class) #self.failIf('caching_policy_manager' in self.portal.objectIds()) self.portal.portal_quickinstaller.uninstallProducts(['CacheSetup']) # now the new types are gone again self.assertEqual(set(installed_types).issubset(set(portal_factory.getFactoryTypes())), False) cpm = self.portal.caching_policy_manager self.assertEqual(cpm.__class__, original_class) lp = cpm.listPolicies() self.assertEqual(len(lp), 1) (id, p) = lp[0] self.assertEqual(id, 'foo') self.assertEqual(p.getPredicate(), 'python:0')
def needsTypeFieldSchemaUpgrade(self): """Check for old straying type field remnants, they indicate a typeField migration need """ print >> self.out, u"typeField schema migration:" print >> self.out, u"---------------------------" ct = getToolByName(self.site, "portal_catalog") bibtool = getToolByName(self.site, "portal_bibliography") # detect reference_types that contain the typeField ReferenceClasses_with_typeField = [ t["klass"] for t in listTypes() if (t["meta_type"] in bibtool.getReferenceTypes()) and ("publication_type" in [field.getName() for field in t["schema"].fields()]) ] ReferenceTypes_with_typeField = tuple([klass.meta_type for klass in ReferenceClasses_with_typeField]) brains = ct(portal_type=ReferenceTypes_with_typeField, Language="all") # check ALL(!) brains if we really need schema upgrade for old typeField: 'type' -> 'publication_type' for brain in brains: old_typeField_value = getattr(brain.getObject(), "type", False) # to avoid mismatch with the BaseObject's type definition (alias for schema) check # for a unicode value in typeField if old_typeField_value and (type(old_typeField_value) == type(u"")): print >> self.out, u" Upgrade of typeField required." return True print >> self.out, u" No typeField schema upgrade needed." print >> self.out return False
def initialize(context): import ubify.coretypes.content from Products.ATContentTypes.permission import permissions content_types, constructors, ftis = process_types(listTypes(PROJECTNAME), PROJECTNAME) allTypes = zip(content_types, constructors) for atype, constructor in allTypes: kind = "%s: %s" % (PROJECTNAME, atype.archetype_name) if atype.portal_type not in TYPES_NEW: ContentInit( kind, content_types=(atype, ), permission=permissions[atype.portal_type], extra_constructors=(constructor, ), ).initialize(context) else: ContentInit( kind, content_types=(atype, ), permission=DEFAULT_ADD_CONTENT_PERMISSION, extra_constructors=(constructor, ), ).initialize(context) ModuleSecurityInfo("ubify.coretypes").declarePublic("get_action_mapped")
def initialize(context): """Initializer called when used as a Zope 2 product.""" import ubify.recyclebin.content from Products.ATContentTypes.permission import permissions content_types, constructors, ftis = process_types( listTypes(PROJECTNAME), PROJECTNAME) allTypes = zip(content_types, constructors) for atype, constructor in allTypes: kind = "%s: %s" % (PROJECTNAME, atype.archetype_name) if atype.portal_type not in TYPES_NEW: ContentInit( kind, content_types = (atype,), permission = permissions[atype.portal_type], extra_constructors = (constructor,), ).initialize(context) else: ContentInit( kind, content_types = (atype,), permission = DEFAULT_ADD_CONTENT_PERMISSION, extra_constructors = (constructor,), ).initialize(context)
def initialize(context): ##Import Types here to register them from content import coreblog2 from content import coreblogstufffolder from content import coreblogentry from content import coreblogcategory from content import coreblogcomment from content import coreblogtrackback content_types, constructors, ftis = process_types(listTypes(PROJECTNAME), PROJECTNAME) utils.ToolInit( 'COREBlog Tool', tools=(COREBlogTool.COREBlog2Tool, ), product_name=PROJECTNAME, icon='tool.gif', ).initialize(context) permissions = initialize_permissions() allTypes = zip(content_types, constructors) for atype, constructor in allTypes: kind = "%s: %s" % (config.PROJECTNAME, atype.archetype_name) utils.ContentInit( kind, content_types=(atype, ), permission=permissions[atype.portal_type], extra_constructors=(constructor, ), fti=ftis, ).initialize(context)
def initialize(context): # import at initialize: this let a chance to 3rd party products to change # config before deciding to patch from Products.PloneGlossary import patches patches # pyflakes from Products.PloneGlossary.permissions import add_permissions # used by test framework if 'ZOPETESTCASE' in os.environ: from . import examples examples # pyflakes # Import types listOfTypes = listTypes(PROJECTNAME) content_types, constructors, ftis = process_types(listOfTypes, PROJECTNAME) for content_type, constructor in zip(content_types, constructors): kind = "%s: %s" % (PROJECTNAME, content_type.__name__) ContentInit( kind, content_types=(content_type, ), permission=add_permissions[content_type.__name__], extra_constructors=(constructor, ), fti=ftis, ).initialize(context) # Import tool ToolInit('%s Tool' % PROJECTNAME, tools=(PloneGlossaryTool, ), icon='tool.gif').initialize(context)
def initialize(context): from content import BlogEntry from content import Blog from content import BlogFolder listOfTypes = listTypes(PROJECTNAME) content_types, constructors, ftis = process_types(listOfTypes, PROJECTNAME) from Products.SimpleBlog.Permissions import permissions allTypes = zip(content_types, constructors) wireAddPermissions() for atype, constructor in allTypes: kind = "%s: %s" % (PROJECTNAME, atype.archetype_name) ContentInit( kind, content_types=(atype, ), permission=permissions[atype.portal_type], extra_constructors=(constructor, ), fti=ftis, ).initialize(context) from SimpleBlogTool import SimpleBlogManager utils.ToolInit( 'SimpleBlog manager', tools=(SimpleBlogTool.SimpleBlogManager, ), icon='tool.gif', ).initialize(context)
def initialize(context): ##Import Types here to register them from Products.PloneTemplates.content import Template content_types, constructors, ftis = process_types( listTypes(PROJECTNAME), PROJECTNAME) from Products.PloneTemplates.Permissions import permissions allTypes = zip(content_types, constructors) wireAddPermissions() for atype, constructor in allTypes: kind = "%s: %s" % (PROJECTNAME, atype.archetype_name) ContentInit( kind, content_types = (atype,), permission = permissions[atype.portal_type], extra_constructors = (constructor,), fti = ftis, ).initialize(context) from Products.PloneTemplates.TemplateTool import PloneTemplatesTool ToolInit( 'PloneTemplates tool', tools=(PloneTemplatesTool,), icon='tool.gif', ).initialize(context) # patch types import Products.PloneTemplates.PatchSchemas
def initialize(context): import ubify.coretypes.content from Products.ATContentTypes.permission import permissions content_types, constructors, ftis = process_types( listTypes(PROJECTNAME), PROJECTNAME) allTypes = zip(content_types, constructors) for atype, constructor in allTypes: kind = "%s: %s" % (PROJECTNAME, atype.archetype_name) if atype.portal_type not in TYPES_NEW: ContentInit( kind, content_types = (atype,), permission = permissions[atype.portal_type], extra_constructors = (constructor,), ).initialize(context) else: ContentInit( kind, content_types = (atype,), permission = DEFAULT_ADD_CONTENT_PERMISSION, extra_constructors = (constructor,), ).initialize(context) ModuleSecurityInfo("ubify.coretypes").declarePublic("get_action_mapped")
def initialize(context): ##Import Types here to register them from content import coreblog2 from content import coreblogstufffolder from content import coreblogentry from content import coreblogcategory from content import coreblogcomment from content import coreblogtrackback content_types, constructors, ftis = process_types( listTypes(PROJECTNAME), PROJECTNAME) utils.ToolInit('COREBlog Tool', tools=(COREBlogTool.COREBlog2Tool,), product_name=PROJECTNAME, icon='tool.gif', ).initialize(context) permissions = initialize_permissions() allTypes = zip(content_types, constructors) for atype, constructor in allTypes: kind = "%s: %s" % (config.PROJECTNAME, atype.archetype_name) utils.ContentInit( kind, content_types = (atype,), permission = permissions[atype.portal_type], extra_constructors = (constructor,), fti = ftis, ).initialize(context)
def initialize(context): import content ########## # Add our content types # A little different from the average Archetype product # due to the need to individualize some add permissions. # # This approach borrowed from ATContentTypes # listOfTypes = listTypes(PROJECTNAME) content_types, constructors, ftis = process_types(listOfTypes, PROJECTNAME) allTypes = zip(content_types, constructors) for atype, constructor in allTypes: kind = "%s: %s" % (PROJECTNAME, atype.archetype_name) if atype.portal_type == 'SalesforcePFGAdapter': permission = SFA_ADD_CONTENT_PERMISSION else: permission = ADD_CONTENT_PERMISSION utils.ContentInit( kind, content_types=(atype, ), permission=permission, extra_constructors=(constructor, ), fti=ftis, ).initialize(context) ModuleSecurityInfo('Products.PloneFormGen').declarePublic( 'SalesforcePFGAdapterMessageFactory') ModuleSecurityInfo('Products.PloneFormGen').declarePublic('HAS_PLONE25')
def install(self): out = StringIO() qi = getToolByName(self, 'portal_quickinstaller') installable = [ prod['id'] for prod in qi.listInstallableProducts() ] installed = [ prod['id'] for prod in qi.listInstalledProducts() ] for product in (DEPENDENCIES): if product not in installable + installed: raise RuntimeError('%s not available' % product) if product in installable: qi.installProduct(product) print >>out, 'Install %s' % product installTypes(self, out, listTypes(PROJECTNAME), PROJECTNAME) install_subskin(self, out, GLOBALS) install_cmfcpviews(self, out) site_properties = getToolByName(self, 'portal_properties').site_properties if site_properties.hasProperty('typesUseViewActionInListings'): types = list(site_properties.getProperty('typesUseViewActionInListings')) types.append('FlashMovie') site_properties.manage_changeProperties(typesUseViewActionInListings=types) print >> out, "Added FlashMovie in typesUseViewActionInListings\n" print >> out, "Successfully installed %s." % PROJECTNAME return out.getvalue()
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) #register the folderish items in portal_properties/site_properties site_props = getToolByName(self, 'portal_properties').site_properties use_folder_tabs = site_props.getProperty('use_folder_tabs', None) if not 'FaqFolder' in use_folder_tabs: site_props._updateProperty('use_folder_tabs', tuple(use_folder_tabs) + ('FaqFolder',)) print >> out, "Added FaqFolder to portal_properties/site_properties/use_folder_tabs" use_folder_contents = site_props.getProperty('use_folder_contents', None) if not 'FaqFolder' in use_folder_tabs: site_props._updateProperty('use_folder_contents', tuple(use_folder_tabs) + ('FaqFolder',)) print >> out, "Added FaqFolder to portal_properties/site_properties/use_folder_contents" print >> out, "Successfully installed %s." % PROJECTNAME return out.getvalue()
def needsTypeFieldSchemaUpgrade(self): """Check for old straying type field remnants, they indicate a typeField migration need """ print >> self.out, u'typeField schema migration:' print >> self.out, u'---------------------------' ct = getToolByName(self.site, 'portal_catalog') bibtool = getToolByName(self.site, 'portal_bibliography') # detect reference_types that contain the typeField ReferenceClasses_with_typeField = [ t['klass'] for t in listTypes() if (t['meta_type'] in bibtool.getReferenceTypes()) and ( 'publication_type' in [field.getName() for field in t['schema'].fields()]) ] ReferenceTypes_with_typeField = tuple( [klass.meta_type for klass in ReferenceClasses_with_typeField]) brains = ct(portal_type=ReferenceTypes_with_typeField, Language='all') # check ALL(!) brains if we really need schema upgrade for old typeField: 'type' -> 'publication_type' for brain in brains: old_typeField_value = getattr(brain.getObject(), 'type', False) # to avoid mismatch with the BaseObject's type definition (alias for schema) check # for a unicode value in typeField if old_typeField_value and (type(old_typeField_value) == type(u'')): print >> self.out, u' Upgrade of typeField required.' return True print >> self.out, u' No typeField schema upgrade needed.' print >> self.out return False
def install(self): """ Installs the product. """ out = StringIO() # install depending products installDependencies(self, out) # install types installTypes(self, out, listTypes(PRODUCT_NAME), PRODUCT_NAME) # install subskins install_subskin(self, out, GLOBALS) # install workflows setupWorkflow(self, out) # install tools # register tool to Plone's preferences panel # enable portal_factory for given types factory_tool = getToolByName(self, 'portal_factory') factory_types=[ ECRB_NAME, ] + factory_tool.getFactoryTypes().keys() factory_tool.manage_setPortalFactoryTypes(listOfTypeIds=factory_types) print >> out, "Successfully installed %s." % PRODUCT_NAME return out.getvalue()
def at_processing(context): """Registers Archetypes content types """ import document, paragraphs from security import DEFAULT_ADD_CONTENT_PERMISSION from security import ADD_CONTENT_PERMISSIONS contentTypes, constructors, ftis = process_types(listTypes(PROJECTNAME), PROJECTNAME) ContentInit( PROJECTNAME + ' Content', content_types = contentTypes, permission = DEFAULT_ADD_CONTENT_PERMISSION, extra_constructors = constructors, fti = ftis, ).initialize(context) for i in range(0, len(contentTypes)): name = contentTypes[i].__name__ if not name in ADD_CONTENT_PERMISSIONS: continue context.registerClass(meta_type = ftis[i]['meta_type'], constructors = (constructors[i],), permission = ADD_CONTENT_PERMISSIONS[name])
def migrateTypeFieldSchema(self): """Migrate typeField id 'type' to new (less overloaded) id 'publication_type' """ ct = getToolByName(self.site, 'portal_catalog') bibtool = getToolByName(self.site, 'portal_bibliography') # detect reference_types that contain the typeField ReferenceClasses_with_typeField = [ t['klass'] for t in listTypes() if (t['meta_type'] in bibtool.getReferenceTypes()) and ( 'publication_type' in [field.getName() for field in t['schema'].fields()]) ] ReferenceTypes_with_typeField = tuple( [klass.meta_type for klass in ReferenceClasses_with_typeField]) brains = ct(meta_type=ReferenceTypes_with_typeField, Language='all') for brain in brains: bibref_item = brain.getObject() # this one is the old typeField value old_typeField_value = copy.deepcopy( getattr(bibref_item, 'type', False)) # this one the new typeField with id 'publication_type' new_typeField = bibref_item.Schema().get('publication_type', None) # if there is no formerly set typeField value, just do the schema update if new_typeField and (type(old_typeField_value) == type( bibref_item.schema)): bibref_item._updateSchema() try: print >> self.out, u' Only simple schema update needed for ObjectId %s: typeField value=\'%s\'' % ( brain.getId, bibref_item.getPublication_type()) except UnicodeDecodeError: print >> self.out, u' Only simple schema update needed for ObjectId %s: typeField value=\'%s\'' % ( brain.getId, '<HIDDEN: value contains non-ASCII characters>') # but if there is an old 'type' attribute in the bibref_item object, update the new typeField with its value # to avoid mismatch with the BaseObject's type definition (alias for schema) check for a unicode value in typeField elif new_typeField and (type(old_typeField_value) == type(u'')): delattr(bibref_item, 'type') bibref_item._updateSchema() bibref_item.edit(publication_type=old_typeField_value) try: print >> self.out, u' Migrating typeField of ObjectId %s: value=\'%s\'' % ( brain.getId, bibref_item.getPublication_type()) except UnicodeDecodeError: print >> self.out, u' Migrating typeField of ObjectId %s: value=\'%s\'' % ( brain.getId, '<HIDDEN: value contains non-ASCII characters>') else: print >> self.out, u' typeField schema update for ObjectId: %s failed.' % bibref_item.getId( ) print >> self.out
def getQuillsAddPermissions(): """Return a sequence of all the 'add' permissions for Quills types. """ qtypes = atapi.listTypes(config.PROJECTNAME) perms = [] for atype in qtypes: permission = _formatPermissionForType(atype['portal_type']) perms.append(permission) return perms
def initialize(): permissions = {} types = atapi.listTypes(config.PROJECTNAME) for atype in types: permission = "%s: Add %s" % (config.PROJECTNAME, atype['portal_type']) permissions[atype['portal_type']] = permission setDefaultRoles(permission, ('Manager', 'Owner')) return permissions
def install(self): out = StringIO() installTypes(self, out, listTypes(PKG_NAME), PKG_NAME) install_subskin(self, out, GLOBALS) setupActions(self) print >> out, "Successfully installed %s." % PKG_NAME return out.getvalue()
def install(self): out = StringIO() if INSTALL_DEMO_TYPES: installTypes(self, out, listTypes(PROJECTNAME), PROJECTNAME) install_subskin(self, out, GLOBALS) setupProperties(self, out) configureFormController(self, out) out.write("Successfully installed %s." % PROJECTNAME) return out.getvalue()
def install(self): out = StringIO() if INSTALL_SAMPLE_TYPES: installTypes(self, out, listTypes(PROJECTNAME), PROJECTNAME) install_subskin(self, out, GLOBALS) print >> out, "Successfully installed %s." % PROJECTNAME return out.getvalue()
def initialize(): permissions = {} types = atapi.listTypes(config.PROJECTNAME) for atype in types: permission = _formatPermissionForType(atype['portal_type']) permissions[atype['portal_type']] = permission cmfpermissions.setDefaultRoles(permission, ('Manager','Owner', 'Contributor')) ManageTeamMembership = 'Manage team memberships' cmfpermissions.setDefaultRoles(ManageTeamMembership, ('Manager',)) return permissions
def reindexNearlyAll(portal): """ We need the object_provides index to reflect some of our new interfaces. """ mytypes = [t['portal_type'] for t in listTypes(PROJECTNAME)] catalog = getToolByName(portal, 'portal_catalog') for brain in catalog(portal_type=mytypes): brain.getObject().reindexObject('object_provides')