def initialize(context): # process our custom types if HAS_LINGUA_PLONE: from Products.LinguaPlone.public import process_types from Products.LinguaPlone.public import listTypes else: from Products.Archetypes.atapi import process_types from Products.Archetypes.atapi import listTypes ToolInit('ATContentTypes tool', tools=(ATCTTool, FactoryTool, MetadataTool), icon='tool.gif').initialize(context) listOfTypes = listTypes(PROJECTNAME) content_types, constructors, ftis = process_types( listOfTypes, PROJECTNAME) # Assign an own permission to all content types # Heavily based on Bricolite's code from Ben Saller from Products.ATContentTypes.permission import permissions allTypes = zip(content_types, constructors) 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,), ).initialize(context)
def initialize(context): # process our custom types if HAS_LINGUA_PLONE: from Products.LinguaPlone.public import process_types from Products.LinguaPlone.public import listTypes else: from Products.Archetypes.atapi import process_types from Products.Archetypes.atapi import listTypes ToolInit( 'ATContentTypes tool', tools=(ATCTTool,), icon='tool.gif', ).initialize(context) listOfTypes = listTypes(PROJECTNAME) content_types, constructors, ftis = process_types( listOfTypes, PROJECTNAME) # Assign an own permission to all content types # Heavily based on Bricolite's code from Ben Saller from Products.ATContentTypes.permission import permissions allTypes = zip(content_types, constructors) 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,), ).initialize(context)
def addToFactoryTool(self, out): # make new types use portal_factory ftool = getToolByName(self, 'portal_factory') if ftool: portal_factory_types = ftool.getFactoryTypes().keys() for portalType in [ typeDict['portal_type'] for typeDict in listTypes(PROJECTNAME) ]: if portalType not in portal_factory_types: portal_factory_types.append(portalType) ftool.manage_setPortalFactoryTypes(listOfTypeIds=portal_factory_types) print >> out, 'New types use portal_factory'
def update_metadata(self): self.content_types = {} for atapi_info in atapi.listTypes(): at = atapi_info.copy() if not at["portal_type"] in self.portal.portal_types: continue pt = self.portal.portal_types[at["portal_type"]] at['allowed_types'] = pt.allowed_content_types at["_finishConstruction"] = pt._finishConstruction self.content_types[at["portal_type"]] = at
def initialize(context): """Register content types through Archetypes with Zope and the CMF.""" content_types, constructors, ftis = atapi.process_types( atapi.listTypes(config.PROJECTNAME), config.PROJECTNAME) for atype, constructor in zip(content_types, constructors): utils.ContentInit( "%s: %s" % (config.PROJECTNAME, atype.portal_type), content_types=(atype,), permission=config.ADD_PERMISSIONS[atype.portal_type], extra_constructors=(constructor,), ).initialize(context)
def initialize(context): """Register content types through Archetypes with Zope and the CMF. """ content_types, constructors, ftis = atapi.process_types( atapi.listTypes(config.PROJECTNAME), config.PROJECTNAME) for atype, constructor in zip(content_types, constructors): utils.ContentInit( "%s: %s" % (config.PROJECTNAME, atype.portal_type), content_types=(atype,), permission=config.ADD_PERMISSIONS[atype.portal_type], extra_constructors=(constructor,), ).initialize(context)
def initialize(context): """Register content types through Archetypes with Zope and the CMF. """ from collective.folderishtypes.at import content # nopep8 content_types, constructors, ftis = atapi.process_types( atapi.listTypes(PROJECTNAME), PROJECTNAME ) for atype, constructor in zip(content_types, constructors): utils.ContentInit( "%s: %s" % (PROJECTNAME, atype.portal_type), content_types=(atype,), permission=ADD_PERMISSIONS[atype.portal_type], extra_constructors=(constructor,), ).initialize(context)
def initialize(context): import EntiCriteria listOfTypes = listTypes(PROJECTNAME) content_types, constructors, ftis = process_types(listOfTypes, PROJECTNAME) from redturtle.entiterritoriali.config import default_permission allTypes = zip(content_types, constructors) for atype, constructor in allTypes: kind = "%s: %s" % (PROJECTNAME, atype.archetype_name) ContentInit( kind, content_types=(atype, ), permission=default_permission, extra_constructors=(constructor, ), ).initialize(context)
def initialize(context): import ContentPanels content_types, constructors, ftis = process_types( listTypes(PROJECTNAME), PROJECTNAME) utils.ContentInit( PROJECTNAME + ' Content', content_types = content_types, permission = ADD_CONTENT_PERMISSION, extra_constructors = constructors, fti = ftis, ).initialize(context) utils.ToolInit('CMF ContentPanels Tool', tools=(ContentPanelsTool,), product_name='CMFContentPanels', icon='tool.gif', ).initialize( context )
def initialize(context): """Initializer called when used as a Zope 2 product.""" from Products.CMFCore.utils import ContentInit try: from Products.LinguaPlone import public as atapi except ImportError: from Products.Archetypes import atapi from .table import Table content_types, constructors, ftis = atapi.process_types( atapi.listTypes(config.PROJECTNAME), config.PROJECTNAME) for atype, constructor in zip(content_types, constructors): ContentInit('%s: %s' % (config.PROJECTNAME, atype.meta_type), content_types=(atype,), permission=config.ADD_PERMISSION, extra_constructors=(constructor,), ).initialize(context)
def install(portal): out = StringIO() installTypes(portal, out, listTypes(PROJECTNAME), PROJECTNAME) install_subskin(portal, out, GLOBALS) tabbed_subpages_portal_type = TYPE_PARAMS['TabbedSubpages']['portal_type'] props_tool = getToolByName(portal, 'portal_properties') dpt = list(props_tool.site_properties.default_page_types) if tabbed_subpages_portal_type not in dpt: dpt.append(tabbed_subpages_portal_type) props_tool.site_properties.default_page_types = tuple(dpt) install_resources(portal, out) print >> out, "Successfully installed %s." % PROJECTNAME return out.getvalue()
def initialize(context): """Register content types through Archetypes with Zope and the CMF. """ from Products.CMFCore.utils import ContentInit from plone.app.event.at import content # nopep8 content_types, constructors, ftis = atapi.process_types( atapi.listTypes(packageName), packageName) assert len(content_types) == 1, 'only one new event, please!' for atype, constructor, fti in zip(content_types, constructors, ftis): ContentInit( "%s: %s" % (packageName, atype.portal_type), content_types=(atype,), permission=ADD_PERMISSION, extra_constructors=(constructor,), fti=(fti,), ).initialize(context)
def install(self): out = StringIO() setupTool(self, out) addPrefsPanel(self, out) addActions(self, out) installTypes(self, out, listTypes(PROJECTNAME), PROJECTNAME) addToFactoryTool(self, out) addIndexesToCatalogTool(self, out) addMetadataToCatalogTool(self, out) transaction.savepoint(optimistic=True) autoMigration(self, out) install_subskin(self, out, GLOBALS) out.write("Successfully installed %s." % PROJECTNAME) return out.getvalue()
def initialize(context): import EntiCriteria listOfTypes = listTypes(PROJECTNAME) content_types, constructors, ftis = process_types( listOfTypes, PROJECTNAME) from redturtle.entiterritoriali.config import default_permission allTypes = zip(content_types, constructors) for atype, constructor in allTypes: kind = "%s: %s" % (PROJECTNAME, atype.archetype_name) ContentInit( kind, content_types = (atype,), permission = default_permission, extra_constructors = (constructor,), ).initialize(context)
def initialize(context): # Apply monkey patches from Products.LinguaPlone import patches patches # pyflakes # Initialize content types from Products.LinguaPlone.public import listTypes from Products.LinguaPlone.public import process_types content_types, constructors, ftis = process_types( listTypes("LinguaPlone"), "LinguaPlone") from Products.CMFCore.utils import ContentInit from Products.LinguaPlone import permissions ContentInit( 'LinguaPlone Content', content_types = content_types, permission = permissions.AddPortalContent, extra_constructors = constructors, fti = ftis, ).initialize(context) from Products.LinguaPlone import LanguageIndex context.registerClass( LanguageIndex.LanguageIndex, permission=permissions.AddLanguageIndex, constructors=(LanguageIndex.manage_addLanguageIndexForm, LanguageIndex.manage_addLanguageIndex), icon='www/index.png', visibility=None) # Make selection criteria available for the LanguageIndex from Products.ATContentTypes.criteria import _criterionRegistry from Products.ATContentTypes.criteria.selection import ATSelectionCriterion crit_id = ATSelectionCriterion.meta_type crit_reg = _criterionRegistry index = LanguageIndex.LanguageIndex.meta_type indices = crit_reg.criterion2index.get(crit_id, ()) crit_reg.criterion2index[crit_id] = indices + (index, ) value = crit_reg.index2criterion.get(index, ()) crit_reg.index2criterion[index] = value + (crit_id, )
def initialize(context): # Apply monkey patches from Products.LinguaPlone import patches patches # pyflakes # Initialize content types from Products.LinguaPlone.public import listTypes from Products.LinguaPlone.public import process_types content_types, constructors, ftis = process_types(listTypes("LinguaPlone"), "LinguaPlone") from Products.CMFCore.utils import ContentInit from Products.LinguaPlone import permissions ContentInit( 'LinguaPlone Content', content_types=content_types, permission=permissions.AddPortalContent, extra_constructors=constructors, fti=ftis, ).initialize(context) from Products.LinguaPlone import LanguageIndex context.registerClass( LanguageIndex.LanguageIndex, permission=permissions.AddLanguageIndex, constructors=(LanguageIndex.manage_addLanguageIndexForm, LanguageIndex.manage_addLanguageIndex), icon='www/index.png', visibility=None) # Make selection criteria available for the LanguageIndex from Products.ATContentTypes.criteria import _criterionRegistry from Products.ATContentTypes.criteria.selection import ATSelectionCriterion crit_id = ATSelectionCriterion.meta_type crit_reg = _criterionRegistry index = LanguageIndex.LanguageIndex.meta_type indices = crit_reg.criterion2index.get(crit_id, ()) crit_reg.criterion2index[crit_id] = indices + (index, ) value = crit_reg.index2criterion.get(index, ()) crit_reg.index2criterion[index] = value + (crit_id, )
def initialize(context): 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)): klassname = contentTypes[i].__name__ if not klassname in ADD_CONTENT_PERMISSIONS: continue context.registerClass( meta_type = ftis[i]['meta_type'], constructors = (constructors[i],), permission = ADD_CONTENT_PERMISSIONS[klassname] ) # register custom indexers for relateditems fields from zope.component import provideAdapter from plone.indexer.decorator import indexer from marsapp.content.interfaces import IMarsObject from marsapp.content.schemata import vocabularies from Products.Archetypes.interfaces.field import IReferenceField from Products.CMFCore.utils import getToolByName # allow us to index all related fields on title & desc for ct in contentTypes: for key in ct.schema.keys(): field = ct.schema[key] if (IReferenceField.providedBy(field) and not key in vocabularies.REFERENCEFIELDS_INDEXES): vocabularies.REFERENCEFIELDS_INDEXES[key] = [] if (not field.accessor in vocabularies.REFERENCEFIELDS_INDEXES[ key]): vocabularies.REFERENCEFIELDS_INDEXES[ key].append( field.accessor ) def make_reindex_related(index_name): iname = index_name def reindex_related(obj, *args, **kwargs): catalog = getToolByName(obj, 'reference_catalog') inamee = iname if not inamee in obj.schema.keys(): return field = obj.getField(iname) items = field.getRaw(obj) indexed = [] res = '' if bool(items): if isinstance(items, list): indexed.extend(items) else: indexed.append(items) for sitem in indexed: item = catalog.lookupObject(sitem) if isinstance(item, MarsCategory): try: res += ' / '.join(item.cats_path()) except: pass else: try: res += ' %s' % item.Title() except: pass try: res += ' %s' % item.Description() except: pass try: res += ' %s' % item.description except: pass if not res: res = None return res return reindex_related for field in vocabularies.REFERENCEFIELDS_INDEXES: frn = indexer(IMarsObject)(make_reindex_related(field)) for accessor in vocabularies.REFERENCEFIELDS_INDEXES[field]: provideAdapter(frn, name=accessor)
def listBibReferenceTypes(self): """Return a DisplayList containing all available bibref items """ bib_tool = getToolByName(self, 'portal_bibliography') return DisplayList(tuple([(type['klass'].portal_type, type['klass'].archetype_name) for type in listTypes(BIBLIOGRAPHY_PROJECTNAME) if type['klass'].portal_type in bib_tool.getReferenceTypes() ]))