kotti.message

kotti.message.validate_token(user: kotti.security.Principal, token: str, valid_hrs: int = 24) → bool[source]
>>> from kotti.testing import setUp, tearDown
>>> ignore = setUp()
>>> class User(object):
...     pass
>>> daniel = User()
>>> daniel.name = u'daniel'
>>> alice = User()
>>> alice.name = u'alice'
>>> token = make_token(daniel)
>>> validate_token(daniel, token)
True
>>> validate_token(alice, token)
False
>>> validate_token(daniel, 'foo')
False
>>> token = make_token(daniel, seconds=time.time() - 100000)
>>> validate_token(daniel, token)
False
>>> validate_token(daniel, token, valid_hrs=48)
True
>>> tearDown()
kotti.message.send_email(request: kotti.request.Request, recipients: List[str], template_name: str, template_vars: Optional[Dict[str, str]] = None) → None[source]

General email sender.

Parameters:
  • request (kotti.request.Request) – current request.
  • recipients (list) – list of email addresses. Each email should be a string like: u‘“John Doe” <joedoe@foo.com>’.
  • template_name (string) – asset specification (e.g. ‘mypackage:templates/email.pt’)
  • template_vars (dict) – set of variables present on template.