ploneintranet.invitations package¶
Subpackages¶
Submodules¶
ploneintranet.invitations.events module¶
-
interface
ploneintranet.invitations.events.
ITokenAccepted
¶ Bases:
zope.interface.Interface
-
token_id
= <zope.interface.interface.Attribute object>¶ The id of the Token that was consumed
-
-
class
ploneintranet.invitations.events.
TokenAccepted
(token_id)¶ Bases:
object
Event to be fired whenever a token is consumed
ploneintranet.invitations.interfaces module¶
-
interface
ploneintranet.invitations.interfaces.
IPloneintranetInvitationsLayer
¶ Bases:
zope.interface.Interface
Marker interface that defines a Zope 3 browser layer.
-
interface
ploneintranet.invitations.interfaces.
IToken
¶ Bases:
zope.interface.Interface
Interface for Token class
-
uses
= <zope.interface.interface.Attribute object>¶ The number of uses for this token before it expires
-
id
= <zope.interface.interface.Attribute object>¶ The UUID of this token
-
expiry
= <zope.interface.interface.Attribute object>¶ The datetime this token expires
-
ploneintranet.invitations.invitations module¶
-
class
ploneintranet.invitations.invitations.
InviteUser
(context, request)¶ Bases:
Products.Five.browser.BrowserView
Control panel view for sending invitation emails to potential new users of the Plone site
THIS IS EXAMPLE CODE AND NEEDS ATTENTION.
-
invite_user
(email)¶ Get new token, build email and send it to the given email address
Parameters: email (str) – Email address to send invitation to, and for new user Returns: Tuple of token id and token url
-
-
ploneintranet.invitations.invitations.
_ceil_datetime
(days=3, now=datetime.datetime(2020, 12, 7, 11, 45, 6, 188362))¶ Helper method to ceil the datetime to a quarter of a hour and calculate the total_seconds until that moment.
Parameters: - days (int) – the amount of days from now.
- now (datetime) – The current moment. This is a parameter so we can test.
Returns: (datetime and int)
-
ploneintranet.invitations.invitations.
_get_storage
(clear=False)¶
-
ploneintranet.invitations.invitations.
_store_invite
(token_id, email)¶
-
ploneintranet.invitations.invitations.
accept_invitation
(event)¶ Event handler for
AcceptToken
event fired by invitation frameworkFIXME #1047: this creates a acl user, not a ploneintranet userprofile
Additionally, this code makes the heroic assumption that email == username == userid which is very brittle, see #1043.
Parameters: event ( AcceptToken
) – The event objectReturns:
ploneintranet.invitations.testing module¶
ploneintranet.invitations.token module¶
ploneintranet.invitations.token_utility module¶
-
class
ploneintranet.invitations.token_utility.
TokenUtility
¶ Bases:
object
Utility to generate and consume tokens
-
_consume_token
(token_id)¶ Consume the given token and fire the event
Parameters: token_id (str) – The token id Returns: Whether consumption succeeded or not. It will fail if the token has expired Return type: bool
-
_fetch_token
(token_id)¶ Get an existing token from the token storage
Parameters: token_id (str) – A token id Returns: Token object
-
_get_storage
(clear=False)¶ Look up storage for tokens
Parameters: clear (bool) – Force clear the storage Returns: Token storage
-
generate_new_token
(usage_limit=1, expire_seconds=None, redirect_path=None)¶ Get a new unique token
Parameters: - usage_limit (int, default 1. None for unlimited use.) – The number of times this token is allowed to be consumed before expiring
- expire_seconds (int) – The number of seconds before this token expires
- redirect_path (str) – The optional path to redirect to, relative to the Plone site, after token is accepted
Returns: A tuple containing the id of the generated token and a url that can be used to accept the token
Return type: (token_id, token_url)
-
valid
(token_id)¶ Has the token with the given id expired?
Returns: Whether or not the token has expired Return type: bool
-