How to fetch a user ID by email address
by
T. Kim Nguyen
—
last modified
Jun 05, 2009 04:36 PM
contributed by Andrew Schultz
studentSupervisor = obj.portal_membership.searchMembers('email', obj.getSupervisorEmail())
supervisorUserName = "%(username)s" % studentSupervisor[0]
when you use the searchMembers method, it defaults the username and email (as dictionary objects) as a return.
so for your second line, all you have to do is:
"%(username or email goes here)s" % yourvariable[at index]
to return the email or username without the dictionary markup.
Alternatively:
(studentSupervisorUserName, studentSupervisorEmail) = obj.portal_membership.searchMembers('email', obj.getSupervisorEmail())
One line only, plus no string interpolation (faster).











