plone.api 1.3.3 released

Door Roel Bruggink | Op 14-07-2015
The plone.api is an elegant and simple API, built for humans wishing to develop with Plone. Version 1.3.3 simplifies client code even more with plone.api.content.find and default return values. plone.api is now Plone 5 compatible.

What has changed in version 1.3.3?

Documentation

The documentation has been cleaned and updated!

Plone 5 compatibility

plone.api is now compatible with Plone 5. This includes registry based mail settings.
Note: The Plone 5 test setup uses plone.app.contenttypes instead of Archetypes.

Find content objects

plone.api.content.find wraps the portal_catalog tool. It packs a bit of convenience that cleans up your code quite a bit.
The 'context' argument is used to construct the 'path' query:

# new
find(context=context)
# old
catalog(path='/'.join(context.getPhysicalPath()))

The interfaces' __identifier__ is automatically used for the 'object_provides' argument.

# new
find(object_provides=IContentish)
find(object_provides=[IATDocument, IDexterityItem])
or find(object_provides=IContentish.__identifier__)
# old 
catalog(object_provides=IContentish.__identifier__)
catalog(object_provides=[IATDocument.__identifier__, IDexterityItem.__identifier__])

Products.PrintingMailHost support

plone.api.portal.send_email no longer raises ValueError('MailHost is not configured.') when Products.PrintingMailHost is installed and active.

Support Zope users in env.adopt_user.

plone.api.env.adopt_user(username='zope_admin') now works as expected.

get_registry_record lists a subset of registry keys on error.

plone.api.portal.get_registry_record no longer lists all registry keys. It now lists only keys that contain the passed in record name, instead of all 1500+ keys.

Revoking user roles

Fixed revoke_roles method: now if is't called with obj parameter, it doesn't set inherited roles locally.

Get View

plone.api.content.get_view no longer swallows exception. This means that get_view no longer raises InvalidParameterError when there's an error in the view's __init__.

Deleting multiple objects at once

plone.api.content.delete now accepts a list of objects.

Products.Archetypes is optional 

plone.api now can be used without Products.Archetypes.

Default value for plone.api.content.get_state

plone.api.content.get_state now allows for an optional default value. This is used when no workflow is defined for the object.

# new
state = get_state(obj=context, default=None)
if state is None:
# Do something
# old
try:
state = get_state(obj=context)
except WorkflowException:
# Do something 

 

All commits: https://github.com/plone/plone.api/compare/1.3.2...1.3.3
Changelog: https://github.com/plone/plone.api/blob/1.3.3/docs/CHANGES.rst

A big thank you to cekk, jensens and pbauer for making this release possible!