def setUpContentTypes(self, portal): from plone.dexterity.fti import DexterityFTI from plone.dexterity.fti import register from plone.app.content.interfaces import INameFromTitle from plone.app.dexterity.behaviors.metadata import IOwnership from collective.multilingual.interfaces import IMultilingual bs = ( dottedName(IMultilingual), dottedName(IOwnership), dottedName(INameFromTitle), ) content_types = [ ("Item", "Item", (), bs), ("Container", "Container", ("Item", "Container"), bs), ] # Set up Dexterity-based content types. for portal_type, klass, allowed_content_types, bs in content_types: fti = DexterityFTI(portal_type) fti.allowed_content_types = allowed_content_types fti.behaviors = bs fti.klass = "plone.dexterity.content." + klass register(fti) # There's got to be a better way :-) portal.portal_types._setOb(portal_type, fti)
def addMultilingualBehavior(context): """ """ # XXX: A hack? if not context._profile_path.endswith('policy/profiles/multilingual'): return site = context.getSite() behavior_name = dottedName(IMultilingual) sm = getSiteManager(site) for fti in sm.getAllUtilitiesRegisteredFor(IDexterityFTI): portal_type = fti.id if portal_type in ['Link', 'Image', 'File']: continue if behavior_name in fti.behaviors: continue fti.behaviors = list(fti.behaviors) + [behavior_name] print "Added multilingual behavior to the type '%s'.\n" % portal_type