# HG changeset patch # User Daniele Nicolodi # Date 1313943446 -7200 # Node ID 6a52c9c3d5ff1ea7347af91a4c5fc76c8efae7db # Parent 5c567edc0e6c16d44ef117eaec3d59c761b873b7 Add 'emailaddr' property to User class. diff -r 5c567edc0e6c -r 6a52c9c3d5ff src/ltpdarepo/user.py --- a/src/ltpdarepo/user.py Sun Aug 21 18:17:12 2011 +0200 +++ b/src/ltpdarepo/user.py Sun Aug 21 18:17:26 2011 +0200 @@ -1,3 +1,5 @@ +from email.utils import formataddr + from flask import g from wtforms import validators from wtforms.fields import TextField, PasswordField, BooleanField @@ -65,6 +67,11 @@ def __getitem__(self, name): return getattr(self, name) + @property + def emailaddr(self): + # user email address in the form 'Name Surname ' + return formataddr(('%s %s' % (self.name, self.surname), self.email)) + @staticmethod def load(username): curs = g.db.cursor(DictCursor)