gs.profile.json
API¶
The gs.profile.json
module provides three utility
functions that provide dictionaries that can be easily converted
into a JSON object.
-
user_info
(siteInfo, userInfo)¶ Turn a user-info object into a dictionary
Parameters: - siteInfo (
Products.GSContent.interfaces.IGSSiteInfo
) – The site-information object - userInfo (
Products.GSProfile.interfaces.IGSUserInfo
) – The user-information object
Returns: A dictionary:
id
: the user-identifiername
: the name of the userurl
: the URL of the profile page
Return type: - siteInfo (
-
groups
(siteInfo, userInfo)¶ Get the groups that a person belongs to on a site
Parameters: - siteInfo (
Products.GSContent.interfaces.IGSSiteInfo
) – The site-information object - userInfo (
Products.GSProfile.interfaces.IGSUserInfo
) – The user-information object
Returns: The identifiers for the groups that the user belongs to on the site.
Return type: A list of strings
- siteInfo (
-
email_info
(siteInfo, userInfo)¶ Parameters: - siteInfo (
Products.GSContent.interfaces.IGSSiteInfo
) – The site-information object - userInfo (
Products.GSProfile.interfaces.IGSUserInfo
) – The user-information object
Returns: A dictionary:
all
: all the email addresses.preferred
: the preferred delivery addresses.other
: the verified addresses that are not preferred.unverified
: the email addresses that are yet to be verified.
Return type: - siteInfo (
Example¶
In the following example a userInfo
object is created, and
turned into a dictionary. The list of email addresses and groups
are attached, and the entire thing is converted into a
JSON-formatted string.
r = {}
userInfo = createObject('groupserver.UserFromId',
self.context, userId)
if not userInfo.anonymous:
r = user_info(self.siteInfo, userInfo)
r['email'] = email_info(self.siteInfo, userInfo)
r['groups'] = groups(self.siteInfo, userInfo)
retval = json.dumps(r)
return retval