gs.content.form.api.json API

Design

  • All responses from SiteEndpoint or GroupEndpoint pages are application/json.
  • Those who make a non-submission request to a SiteEndpoint or GroupEndpoint page will receive a response that documents the purpose, actions, and parameters of the endpoint. The purpose is based on the label attribute borrowed from zope.formlib. The actions are based on the use of the zope.formlib.form.action() decorator in the subclass. The documentation of parameters is based on the form’s schema.
  • Validation of submissions to SiteEndpoint or GroupEndpoint will actually check that the submitted data includes all required parameters.
  • SiteEndpoint and GroupEndpoint include a helper method to generate a json response for submissions that generate validation errors.

Using SiteEndpoint and GroupEndpoint

Where possible, I’ve tried to make subclassing SiteEndpoint or GroupEndpoint as similar to subclassing gs.content.form.base.SiteForm or gs.group.form.GroupForm as possible.

Subclasses of SiteEndpoint or GroupEndpoint should use the same zope.formlib.action decorator() as subclasses of gs.content.form.base.SiteForm or gs.group.form.GroupForm to name the methods that handle validation success and failure.

The following attribute from zope.formlib has a slightly different use on a SiteEndpoint or GroupEndpoint page than a gs.content.form.base.SiteForm or gs.group.form.GroupForm page:

label:
A documentation string that is displayed to those who request the page without submitting data.

Finally, scripts submitting data to a SiteEndpoint or GroupEndpoint endpoint will need to include a parameter that indicates which action they are submitting. These actions are listed when non-submitting request is made to the endpoint.

API

An page that implements a JSON API object will usually implement a GroupEndpoint or SiteEndpoint. Both classes inherit from :class`EndpointMixin`.

class gs.content.form.api.json.GroupEndpoint(group, request)

An endpoint for a JSON API request for a group.

Parameters:
  • group – The group.
  • request – The request object.
groupInfo

Information about the group.

siteInfo

Information about the site.

class gs.content.form.api.json.SiteEndpoint(site, request)

An endpoint for a JSON API request for a site.

Parameters:
  • site – The site.
  • request – The request object.
siteInfo

Information about the site.