Package: kitconcept.api
kitconcept.apiA facade enhancing the already amazingplone.api.InstallationAddkitconcept.apias a requirement of your package (in setup.py or setup.cfg).UsageReplace, in your codebase, occurrences offrom plone import apiwithfrom kitconcept import api.Inclusion of api.addonapi.addon.get_addonsReturn a list of addons (kitconcept.api._typing.AddonInformation) in the installation.Example:fromkitconceptimportapifromkitconcept.api._typingimportAddonInformationaddons=api.addon.get_addons()# List of AddonInformationassertisinstance(addons,list)assertisinstance(addons[0],AddonInformation)It is possible to filter the addons using the parameterlimit:fromkitconceptimportapi# Return all valid addonsall_addons=api.addon.get_addons()# Only installed addonsinstalled_addons=api.addon.get_addons(limit="installed")# Only upgradable (already installed) addonsupgradable_addons=api.addon.get_addons(limit="upgradable")# Available addons -- not installedavailable_addons=api.addon.get_addons(limit="available")# It is also possible to get addons not available in the UI# Only broken addons (with installation problems)broken_addons=api.addon.get_addons(limit="broken")# Only non-installable addonsbroken_addons=api.addon.get_addons(limit="non_installable")api.addon.get_addons_idsSimilar toapi.addon.get_addons, but return only the addon ids.Example:fromkitconceptimportapiaddons_ids=api.addon.get_addons_ids()# List of strassertisinstance(addons_ids,list)assertisinstance(addons_ids[0],str)api.addon.getGet information about one addon.Example:fromkitconceptimportapi# Get information about plone.restapiaddon=api.addon.get("plone.restapi")assertaddon.id,"plone.restapi"assertaddon.validisTrueassertaddon.description=="RESTful hypermedia API for Plone."assertaddon.profile_type=="default"assertaddon.version=="8.21.0"api.addon.installInstall an addonExample:fromkitconceptimportapistatus=api.addon.install("plone.restapi")assertstatusisTrueassert"plone.restapi"inapi.addon.get_addons_ids(limit="installed")api.addon.uninstallUninstall an addonExample:fromkitconceptimportapistatus=api.addon.uninstall("plone.restapi")assertstatusisTrueassert"plone.restapi"inapi.addon.get_addons_ids(limit="available")Additions to api.contentapi.content.get_constrainsGet constrains -- limits -- of a folderish content.Example:fromkitconceptimportapiconstrains=api.content.get_constrains(obj)# Constrains are not enabled by defaultassertconstrains.mode=="disabled"# Document is allowed to be added to objassert"Document"inconstrains.allowed_types# Document is a prefered type to be added to objassert"Document"inconstrains.immediately_addable_typesapi.content.set_constrainsSet constrains -- limits -- of a folderish content.Example:fromkitconceptimportapiconstrains=api.content.set_constrains(obj,mode="enabled",allowed_types=["Folder","Image"],immediately_addable_types=["Image",],)# Constrains now enabledassertconstrains.mode=="enabled"# Folder and Image are allowed to be added to objassert"Folder"inconstrains.allowed_typesassert"Image"inconstrains.allowed_types# Image is a prefered type to be added to objassert"Image"inconstrains.immediately_addable_typesapi.content.serializeSerialize an object, using the serializers defined in plone.restapi.Example:fromkitconceptimportapiportal=api.portal.get()data=api.content.serialize(portal)# data is a dictionaryassertisinstance(data,dict)# We have the serialized infoassertdata["@type"]=="Plone Site"assertdata["id"]=="plone"assertdata["title"]=="Site"Inclusion of api.ftiapi.fti.get_typesReturn a dictionary with all FTI's registered for the Portal.Example:fromkitconceptimportapifromplone.dexterity.ftiimportDexterityFTIftis=api.fti.get_types()# Dictionary with FTIassertisinstance(ftis,dict)# Document FTI should be presentassert"Document"inftisassertisinstance(ftis["Document"],DexterityFTI)api.fti.getReturn a FTI for a type.Example:fromkitconceptimportapifromplone.dexterity.ftiimportDexterityFTIfti=api.fti.get(type="Document")# FTI for Document content typeassertisinstance(fti,DexterityFTI)assertfti.id=="Documentapi.fti.behaviors_for_typeReturn a list of behaviors for a type.Example:fromkitconceptimportapifromplone.dexterity.ftiimportDexterityFTIbehaviors=api.fti.behaviors_for_type(type="Document")# List of behaviors for Documentassertisinstance(behaviors,list)assert"plone.dublincore"inbehaviorsapi.fti.get_behavior_registrationReturn a list of behaviors for a type.Example:fromkitconceptimportapifromplone.behavior.registrationimportBehaviorRegistrationbehavior=api.fti.get_behavior_registration(name="plone.dublincore")# Behavior registration infoassertisinstance(behavior,BehaviorRegistration)assertbehavior.title=="Dublin Core metadata"api.fti.add_behavior_for_typeAdds the given behavior to the given portal type.Example:fromkitconceptimportapiapi.fti.add_behavior_for_type("Document","plone.leadimage")behaviors=api.fti.behaviors_for_type(type="Document")# List of behaviors for Documentassertisinstance(behaviors,list)assert"plone.leadimage"inbehaviorsapi.fti.remove_behavior_for_typeRemoves the given behavior from the given portal type.Example:fromkitconceptimportapiapi.fti.remove_behavior_for_type("Document","plone.allowdiscussion")behaviors=api.fti.behaviors_for_type(type="Document")# List of behaviors for Documentassertisinstance(behaviors,list)assert"plone.allowdiscussion"notinbehaviorsInclusion of api.vocabularyapi.vocabulary.get_vocabulary_namesReturn a list of names for all vocabulariesExample:fromkitconceptimportapivocabularies=api.addon.get_vocabulary_names()# List of strassertisinstance(vocabularies,list)assertisinstance(vocabularies[0],str)assert"plone.app.vocabularies.Month"invocabulariesapi.vocabulary.getGet one vocabulary.Example:fromkitconceptimportapifromzope.schema.vocabularyimportSimpleVocabulary# Return one vocabularyvocabulary=api.vocabulary.get("plone.app.vocabularies.Month")assertisinstance(vocabulary,SimpleVocabulary)assertvocabulary.getTerm(0).title=="month_jan"Wish Listapi.concent.deserializeplone.app.multilingual: Translations management