ploneintranet.api package

Submodules

ploneintranet.api.previews module

Methods to generate and access preview images on content

ploneintranet.api.previews.events_disable(request=None)

Temporarily disable event-driven preview generation for this request.

Parameters:request (Request) – The request for which events are to be disabled
ploneintranet.api.previews.events_enable(request=None)

Re-enable event-driven preview generation for this request. This only makes sense if you explicitly disabled preview generation, since it is enabled by default.

Parameters:request (Request) – The request for which events were disabled
ploneintranet.api.previews.get_thumbnail_url(obj, relative=False)

Convenience method to get the absolute URL of thumbnail image

Parameters:
  • obj (A Plone content object) – The Plone content object to get preview URLs for
  • relative (boolean) – Specify whether the url should be relative or not
Returns:

The absolute URL to the thumbnail image

Return type:

str

ploneintranet.api.previews.has_thumbnails(obj)

Test if the object has generated previews. As a fallback, also check for the presence of a lead image.

Parameters:obj (A Plone content object) – The Plone object to get previews for
Returns:True if there are previews. False otherwise.
Return type:boolean
ploneintranet.api.previews.is_allowed_document_type(obj)

Check if object can actually be converted :param obj: The Plone object to get previews for :type obj: A Plone content object :return: True if object can be converted :rtype: boolean

ploneintranet.api.testing module

ploneintranet.api.userprofile module

ploneintranet.api.userprofile.avatar_tag(username=None, link_to=None, link_class=None)

Get the tag that renders the user avatar wrapped in a link

Parameters:username (string) – Username for which to get the avatar url
Returns:HTML for the avatar tag
Return type:string
ploneintranet.api.userprofile.avatar_url(username=None)

Get the avatar image url for a user profile

Parameters:username (string) – Username for which to get the avatar url
Returns:absolute url for the avatar image
Return type:string
ploneintranet.api.userprofile.create(username, email=None, password=None, approve=False, properties=None)

Create a Plone Intranet user profile.

Parameters:
  • username (string) – [required] The userid for the new user. WTF? see #1043.
  • email (string) – [required] Email for the new user.
  • password (string) – Password for the new user. If it’s not set we generate a random 12-char alpha-numeric one.
  • approve (boolean) – If True, the user profile will be automatically approved and be able to log in.
  • properties (dict) – User properties to assign to the new user.
Returns:

Newly created user

Return type:

ploneintranet.userprofile.content.userprofile.UserProfile object

ploneintranet.api.userprofile.get(userid)

Get a Plone Intranet user profile by userid. userid == username, but username != getUsername(), see #1043.

Parameters:userid (string) – Usernid of the user profile to be found
Returns:User profile matching the given userid
Return type:ploneintranet.userprofile.content.userprofile.UserProfile object
ploneintranet.api.userprofile.get_current()

Get the Plone Intranet user profile for the current logged-in user

Returns:User profile matching the current logged-in user
Return type:ploneintranet.userprofile.content.userprofile.UserProfile object
ploneintranet.api.userprofile.get_user_suggestions(context=None, full_objects=True, min_matches=5, **kwargs)

This is a wrapper around get_users with the intent of providing staggered suggestion of users for a user picker: 1. Users from the current context (workspace)

If not enough users, add:
  1. Users followed by the current logged-in user If not enough combined users from 1+2, fallback to:
  2. All users in the portal.

List users from catalog, avoiding expensive LDAP lookups.

Parameters:
  • context (Content object) – Any content object that will be used to find the UserResolver context
  • full_objects (boolean) – A switch to indicate if full objects or brains should be returned
  • min_matches (int) – Keeps expanding search until this treshold is reached
Returns:

user brains or user objects

Return type:

iterator

ploneintranet.api.userprofile.get_userids()

For the moment it just returns all the ids of the userprofiles we have in the site.

Returns:the userprofile ids
Return type:iterator
ploneintranet.api.userprofile.get_users(context=None, full_objects=True, **kwargs)

List users from catalog, avoiding expensive LDAP lookups.

Parameters:
  • context (Content object) – Any content object that will be used to find the UserResolver context
  • full_objects (boolean) – A switch to indicate if full objects or brains should be returned
Returns:

user brains or user objects

Return type:

iterator

ploneintranet.api.userprofile.get_users_from_userids_and_groupids(ids=None)

Given a list of userids and groupids return the set of users

FIXME this has to be folded into get_users

Module contents