[CMF-checkins] CVS: CMF/CMFCollector - util.py:1.4

Ken Manheimer klm@zope.com
Mon, 15 Oct 2001 14:42:11 -0400


Update of /cvs-repository/CMF/CMFCollector
In directory cvs.zope.org:/tmp/cvs-serv21648

Modified Files:
	util.py 
Log Message:
Get the email more cleanly (and the full_name, though collector
provisions for it are currently half-assed, because it's not standard
and collector doesn't add it properly).


=== CMF/CMFCollector/util.py 1.3 => 1.4 ===
                     inpre = 1
         got.append(' ' + i)
-    return string.join(got, '\n')
+    return string.strip(string.join(got, '\n'))
 
 def add_local_role(object, userid, roleid):
     """Add object roleid for userid if not already there."""
@@ -144,15 +144,15 @@
     mbrtool = getToolByName(self, 'portal_membership')
     user = mbrtool.getMemberById(userid)
     if user is not None:
+        if not user.hasProperty('email'):
+            return (None, None)         # Not worth bothering.
         email = None
         name = userid
-        try: 
-            email = user.email
-            name = email.full_name
-        except AttributeError:
-            pass
-        if email:
-            if '.' in name or ',' in name:
-                name = '"%s"' % name
-            return (name or userid, email)
+        email = user.getProperty('email')
+        name = ((user.hasProperty('full_name') 
+                 and user.getProperty('full_name'))
+                or str(user))
+        if '.' in name or ',' in name:
+            name = '"%s"' % name
+        return (name, email)
     return (None, None)