Skip to content

Commit b2caa0b

Browse files
committed
Update docs. Correct errors reported by setup.py build_docs. Add rest
interface and link to rest doc to features page. Add link to xmlrpc doc to features page. Add rest doc to index. Update rest doc, hopefully clarify confusing use of parameters in patch action section. Fix code examples in "Adding new rest endpoints" section. Fix example adding import of exception.
1 parent 72b3a45 commit b2caa0b

File tree

3 files changed

+44
-27
lines changed

3 files changed

+44
-27
lines changed

doc/features.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,17 @@ from Ka-Ping Yee in the Software Carpentry "Track" design competition.
104104

105105
*xmlrpc interface*
106106
- simple remote tracker interface with basic HTTP authentication
107+
available at the /xmlrpc endpoint.
107108
- provides same access to tracker as roundup-admin, but based on
108109
XMLRPC calls
110+
- see the `xmlrpc guide`_ for more details simple clients etc.
111+
112+
*restful interface*
113+
- accessible using basic HTTP authentication at /rest starting point
114+
- see the `rest guide`_ for details.
109115

110116
.. _sqlite: http://www.hwaci.com/sw/sqlite/
111117
.. _mysql: https://pypi.org/project/MySQL-python/
112118
.. _postgresql: http://initd.org/software/initd/psycopg
113-
119+
.. _`xmlrpc guide`: xmlrpc.html
120+
.. _`rest guide`: rest.html

doc/index.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Contents
1919
admin_guide
2020
debugging
2121
xmlrpc
22+
rest
2223
overview
2324
Design (original) <design>
2425
developers

doc/rest.txt

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ from relative REST-API links for brevety.
3636
Summary
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.
4040
This is currently hard-coded for the standard tracker schema shipped
4141
with roundup and will display a summary of open issues.
4242

@@ -136,13 +136,13 @@ empty new value.
136136

137137
Finally 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
140140
of ``add``, ``replace``, ``remove``, only for an item (not for a
141141
property) an additional operator ``action`` is supported. If no operator
142142
is specified, the default is ``replace``. The first three operators are
143143
self explanatory. For an ``action`` operator an ``@action_name`` and
144144
optional ``@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
148148
inverse of ``retire``, the item is again visible.
@@ -198,9 +198,10 @@ Adding new rest endpoints
198198
Add or edit the file interfaces.py at the root of the tracker
199199
directory.
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+
261269
Searches and selection
262270
======================
263271

@@ -271,9 +279,9 @@ selectize.js, chosen etc. These tools can query a remote data provider
271279
to get a list of items for the user to select from.
272280

273281
Consider 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

290298
Sets up a box that a user can type the word "request" into. Then
291299
selectize.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

311320
selectize.js will look at these objects (as passed to
312321
callback(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
316325
issues. Only 440 had the word "request" somewhere in the title greatly
317326
reducing 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.
326335
Hopefully future enhancements will allow get on a collection to
327336
include other fields. Why do we want this? Selectize.js can set up
328337
option 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

Comments
 (0)