Enhanced Python API for the Plone Content Management System
Project description
kitconcept.api
A facade enhancing the already amazing plone.api.
Installation
Add kitconcept.api
as a requirement of your package (in setup.py or setup.cfg).
Usage
Replace, in your codebase, occurrences of from plone import api
with from kitconcept import api
.
Inclusion of api.addon
api.addon.get_addons
Return a list of addons (kitconcept.api._typing.AddonInformation
) in the installation.
Example:
from kitconcept import api
from kitconcept.api._typing import AddonInformation
addons = api.addon.get_addons()
# List of AddonInformation
assert isinstance(addons, list)
assert isinstance(addons[0], AddonInformation)
It is possible to filter the addons using the parameter limit
:
from kitconcept import api
# Return all valid addons
all_addons = api.addon.get_addons()
# Only installed addons
installed_addons = api.addon.get_addons(limit="installed")
# Only upgradable (already installed) addons
upgradable_addons = api.addon.get_addons(limit="upgradable")
# Available addons -- not installed
available_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 addons
broken_addons = api.addon.get_addons(limit="non_installable")
api.addon.get_addons_ids
Similar to api.addon.get_addons
, but return only the addon ids.
Example:
from kitconcept import api
addons_ids = api.addon.get_addons_ids()
# List of str
assert isinstance(addons_ids, list)
assert isinstance(addons_ids[0], str)
api.addon.get
Get information about one addon.
Example:
from kitconcept import api
# Get information about plone.restapi
addon = api.addon.get("plone.restapi")
assert addon.id, "plone.restapi"
assert addon.valid is True
assert addon.description == "RESTful hypermedia API for Plone."
assert addon.profile_type == "default"
assert addon.version == "8.21.0"
api.addon.install
Install an addon
Example:
from kitconcept import api
status = api.addon.install("plone.restapi")
assert status is True
assert "plone.restapi" in api.addon.get_addons_ids(limit="installed")
api.addon.uninstall
Uninstall an addon
Example:
from kitconcept import api
status = api.addon.uninstall("plone.restapi")
assert status is True
assert "plone.restapi" in api.addon.get_addons_ids(limit="available")
Additions to api.content
api.content.get_constrains
Get constrains -- limits -- of a folderish content.
Example:
from kitconcept import api
constrains = api.content.get_constrains(obj)
# Constrains are not enabled by default
assert constrains.mode == "disabled"
# Document is allowed to be added to obj
assert "Document" in constrains.allowed_types
# Document is a prefered type to be added to obj
assert "Document" in constrains.immediately_addable_types
api.content.set_constrains
Set constrains -- limits -- of a folderish content.
Example:
from kitconcept import api
constrains = api.content.set_constrains(
obj,
mode="enabled",
allowed_types=["Folder", "Image"],
immediately_addable_types=[
"Image",
],
)
# Constrains now enabled
assert constrains.mode == "enabled"
# Folder and Image are allowed to be added to obj
assert "Folder" in constrains.allowed_types
assert "Image" in constrains.allowed_types
# Image is a prefered type to be added to obj
assert "Image" in constrains.immediately_addable_types
api.content.serialize
Serialize an object, using the serializers defined in plone.restapi.
Example:
from kitconcept import api
portal = api.portal.get()
data = api.content.serialize(portal)
# data is a dictionary
assert isinstance(data, dict)
# We have the serialized info
assert data["@type"] == "Plone Site"
assert data["id"] == "plone"
assert data["title"] == "Site"
Inclusion of api.vocabulary
api.vocabulary.get_vocabulary_names
Return a list of names for all vocabularies
Example:
from kitconcept import api
vocabularies = api.addon.get_vocabulary_names()
# List of str
assert isinstance(vocabularies, list)
assert isinstance(vocabularies[0], str)
assert "plone.app.vocabularies.Month" in vocabularies
api.vocabulary.get
Get one vocabulary.
Example:
from kitconcept import api
from zope.schema.vocabulary import SimpleVocabulary
# Return one vocabulary
vocabulary = api.vocabulary.get("plone.app.vocabularies.Month")
assert isinstance(vocabulary, SimpleVocabulary)
assert vocabulary.getTerm(0).title == "month_jan"
Wish List
- Get behaviors for FTI
- api.concent.deserialize
- plone.app.multilingual: Translations management
Status
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file kitconcept.api-1.0.0a1.tar.gz
.
File metadata
- Download URL: kitconcept.api-1.0.0a1.tar.gz
- Upload date:
- Size: 20.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fafec8c12c642d0756e224e0aa47138ceec6a7fe73dee8b09a249a705143b155 |
|
MD5 | 03112ad1ccfc7de45a1b365f836f7b29 |
|
BLAKE2b-256 | db90c3b0bb6705c463a6dcfdbde379a55af5e7ba74db354a41edcf5829bae864 |
File details
Details for the file kitconcept.api-1.0.0a1-py3-none-any.whl
.
File metadata
- Download URL: kitconcept.api-1.0.0a1-py3-none-any.whl
- Upload date:
- Size: 22.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26e3fb3108f6058fc4a7b35a058660d05e049935e49d67023845c835c39047ac |
|
MD5 | 1f83e6bdb8ca191da4e97e6a13de3c1b |
|
BLAKE2b-256 | 96c08c76a81a83d1dbc639dbcf1511e01654ff7c236ee8ad6a5e41f89f6a2214 |