gs.profile.json Documentation

Author:Michael JasonSmith
Contact:Michael JasonSmith <mpj17@onlinegroups.net>
Date:2015-06-18
Organization:GroupServer.org
Copyright:This document is licensed under a Creative Commons Attribution-Share Alike 4.0 International License by OnlineGroups.net.

This product provides a view of a profile of a GroupServer group member in JSON format, which is used by the member export system. This product also provides some utilities that are used to format user-objects so they can be formatted into JSON object.

Contents:

JSON view of a profile page

The JSON view of the profile, profile.json in the profile context, returns the profile information to people who are logged in. It is used by the gs.group.member.export system to produce a CSV of profile information for the group members.

See also:The gs.search.people product allows external systems to get a JSON view of a profile <https://github.com/groupserver/gs.search.people>

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-identifier
  • name: the name of the user
  • url: the URL of the profile page

Return type:

collections.OrderedDict

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

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:

collections.OrderedDict

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

Changelog

1.1.0 (2015-06-17)

1.0.0 (2015-02-03)

Initial version. Prior to the creation of this product the profile information was only available as HTML.

Indices and tables