# HG changeset patch # User Thierry Florac # Date 1506948282 -7200 # Node ID 39b5457b87f2dff0f9d30d7d0c44df98126dc97c # Parent e3f804db3e6f9b8911a15763b4a4b4f8f5d4b57f Added local user mail adapter diff -r e3f804db3e6f -r 39b5457b87f2 src/pyams_security/plugin/userfolder.py --- a/src/pyams_security/plugin/userfolder.py Thu Sep 28 15:02:44 2017 +0200 +++ b/src/pyams_security/plugin/userfolder.py Mon Oct 02 14:44:42 2017 +0200 @@ -36,7 +36,7 @@ from chameleon.zpt.template import PageTemplateFile from persistent import Persistent from pyams_security.principal import PrincipalInfo -from pyams_utils.adapter import adapter_config +from pyams_utils.adapter import adapter_config, ContextAdapter from pyams_utils.html import html_to_text from pyams_utils.registry import query_utility, get_utility from pyams_utils.request import check_request @@ -133,6 +133,19 @@ title=user.title) +try: + from pyams_mail.interfaces import IPrincipalMailInfo +except ImportError: + pass +else: + @adapter_config(context=ILocalUser, provides=IPrincipalMailInfo) + class UserPrincipalMailInfoAdapter(ContextAdapter): + """User principal mail info adapter""" + + def get_addresses(self): + yield ('{0} {1}'.format(self.context.firstname, self.context.lastname), self.context.email) + + @implementer(IUsersFolderPlugin) class UsersFolder(Folder): """Local users folder"""