@@ -36,7 +36,7 @@ from relative REST-API links for brevety.
3636Summary
3737=======
3838
39- A Summary page can be reached via ``/data/ summary`` via the ``GET`` method.
39+ A Summary page can be reached via ``/summary`` via the ``GET`` method.
4040This is currently hard-coded for the standard tracker schema shipped
4141with roundup and will display a summary of open issues.
4242
@@ -136,13 +136,13 @@ empty new value.
136136
137137Finally the ``PATCH`` method can be applied to individual items, e.g.,
138138``/data/issue/42`` and to properties, e.g., ``/data/issue/42/title``.
139- This method gets an operator ``@op=<method>`` where ``<method`` is one
139+ This method gets an operator ``@op=<method>`` where ``<method> `` is one
140140of ``add``, ``replace``, ``remove``, only for an item (not for a
141141property) an additional operator ``action`` is supported. If no operator
142142is specified, the default is ``replace``. The first three operators are
143143self explanatory. For an ``action`` operator an ``@action_name`` and
144144optional ``@action_argsXXX`` parameters have to be supplied. Currently
145- there are only two actions without parameters , namely ``retire`` and
145+ there are only two actions, neither has args , namely ``retire`` and
146146``restore``. The ``retire`` action on an item is the same as a
147147``DELETE`` method, it retires the item. The ``restore`` action is the
148148inverse of ``retire``, the item is again visible.
@@ -198,9 +198,10 @@ Adding new rest endpoints
198198Add or edit the file interfaces.py at the root of the tracker
199199directory.
200200
201- In that file add (remove indentation) :
201+ In that file add: :
202202
203203 from roundup.rest import Routing, RestfulInstance, _data_decorator
204+ from roundup.exceptions import Unauthorised
204205
205206 class RestfulInstance:
206207
@@ -210,7 +211,7 @@ In that file add (remove indentation):
210211 result = { "hello": "world" }
211212 return 200, result
212213
213- will make a new endpoint .../rest/summary2 that you can test with:
214+ will make a new endpoint .../rest/summary2 that you can test with::
214215
215216 $ curl -X GET .../rest/summary2
216217 {
@@ -219,25 +220,29 @@ will make a new endpoint .../rest/summary2 that you can test with:
219220 }
220221 }
221222
222- Similarly appending this to interfaces.py after summary2:
223+ Similarly appending this to interfaces.py after summary2::
223224
224- @Routing.route("/data/<:class_name>/@schema", 'GET')
225- def get_element_schema(self, class_name, input):
226- result = { "schema": {} }
227- uid = self.db.getuid ()
228- if not self.db.security.hasPermission('View', uid, class_name) :
229- raise Unauthorised('Permission to view %s denied' % class_name)
225+ # handle more endpoints
226+ @Routing.route("/data/<:class_name>/@schema", 'GET')
227+ def get_element_schema(self, class_name, input):
228+ result = { "schema": {} }
229+ uid = self.db.getuid ()
230+ if not self.db.security.hasPermission('View', uid, class_name) :
231+ raise Unauthorised('Permission to view %s denied' % class_name)
230232
231- class_obj = self.db.getclass(class_name)
232- props = class_obj.getprops(protected=False)
233- schema = result['schema']
233+ class_obj = self.db.getclass(class_name)
234+ props = class_obj.getprops(protected=False)
235+ schema = result['schema']
234236
235- for prop in props:
236- schema[prop] = { "type": repr(class_obj.properties[prop]) }
237+ for prop in props:
238+ schema[prop] = { "type": repr(class_obj.properties[prop]) }
237239
238- return result
240+ return result
239241
240- returns some data about the class
242+ ..
243+ the # comment in the example is needed to preserve indention under Class.
244+
245+ returns some data about the class::
241246
242247 $ curl -X GET .../rest/data/issue/@schema
243248 {
@@ -258,6 +263,9 @@ returns some data about the class
258263 }
259264
260265
266+ Adding other endpoints (e.g. to allow an OPTIONS query against
267+ ``/data/issue/@schema``) is left as an exercise for the reader.
268+
261269Searches and selection
262270======================
263271
@@ -271,9 +279,9 @@ selectize.js, chosen etc. These tools can query a remote data provider
271279to get a list of items for the user to select from.
272280
273281Consider a multi-select box for the superseder property. Using
274- selectize.js (and jquery) code similar to:
282+ selectize.js (and jquery) code similar to::
275283
276- $('#superseder').selectize({
284+ $('#superseder').selectize({
277285 valueField: 'id',
278286 labelField: 'title',
279287 searchField: 'title', ...
@@ -289,9 +297,9 @@ selectize.js (and jquery) code similar to:
289297
290298Sets up a box that a user can type the word "request" into. Then
291299selectize.js will use that word to generate an ajax request with the
292- url: .../rest/data/issue?@verbose=2&title=request
300+ url: `` .../rest/data/issue?@verbose=2&title=request``
293301
294- This will return data like:
302+ This will return data like::
295303
296304 {
297305 "data": {
@@ -307,6 +315,7 @@ This will return data like:
307315 "id": "27",
308316 "title": "Request for foo"
309317 },
318+ ...
310319
311320selectize.js will look at these objects (as passed to
312321callback(res.data.collection)) and create a select list from the each
@@ -316,7 +325,7 @@ example above has 440 issues returned from a total of 2000
316325issues. Only 440 had the word "request" somewhere in the title greatly
317326reducing the amount of data that needed to be transferred.
318327
319- Similar things can be set up to search a large list of keywords using
328+ Similar code can be set up to search a large list of keywords using::
320329
321330 .../rest/data/keyword?@verbose=2&name=some
322331
@@ -326,7 +335,7 @@ selections for links and multilinks much easier.
326335Hopefully future enhancements will allow get on a collection to
327336include other fields. Why do we want this? Selectize.js can set up
328337option groups (optgroups) in the select pulldown. So by including
329- status in the returned data:
338+ status in the returned data::
330339
331340 {
332341 "link": ".../rest/data/issue/27",
@@ -335,7 +344,7 @@ status in the returned data:
335344 'status": "open"
336345 },
337346
338- a select widget like:
347+ a select widget like::
339348
340349 === New ===
341350 A request
0 commit comments