apicrud.messaging.confirmation

confirmation.py

Confirmation

Handle the request and confirm actions for a contact.

created 4-apr-2020 by richb@instantlinux.net

Classes

Confirmation(config, models)

Functions for confirming ownership of online email/contact info

URLSafeTimedSerializer(secret_key[, salt, …])

Works like TimedSerializer but dumps and loads into a URL safe string consisting of the upper and lowercase character of the alphabet as well as '_', '-' and '.'.

i18n()

These are keys in a user-provided dict; see the example/i18n_textstrings.py for how to assign string templates for messaging.

Exceptions

NoResultFound(*arg, **kw)

A database result was required but none was found.

class apicrud.messaging.confirmation.Confirmation(config, models)

Functions for confirming ownership of online email/contact info

Parameters
  • config (obj) – the config-file key-value object

  • models (obj) – the models file object

confirm(token)

Confirm a contact if token is still valid

Parameters

token (str) – the token generated previously

Returns

first item is dict with fields as defined in SessionManager.create, second item is the http response code

Return type

tuple

request(id, ttl=None, message='contact_add', func_send=None)

Generate a confirmation token valid for a given period, and send it to the contact identified by id

Parameters
  • id (str) – record ID in contacts table of database

  • ttl (int) – how many seconds before token expires

  • message (str) – key in i18n dict for contact-add message

  • func_send (function) – name of function for sending message

Returns

first item is dict with token and contact-ID, second is the http response code

Return type

tuple