Source

Patchbook /

Filename Size Date modified Message
patchbook
19 B
1.5 KB
2.0 KB
508 B

-- restructuredtext --

PatchBook

A Python wrapper for the Batchbook API.

Methods

GET(method, args, kwargs)

Makes a GET request to the url:

https://test.batchbook.com/service/method/args[0]/args[1]/etc.xml?key0=value0&key1=value1

Example
from patchbook import BatchBook
bb = BatchBook('test.batchbook.com', 'API_KEY_XXXX')
(xml, status) = bb.GET('people', limit=20, offset=0)

Will return a lxml objectfied tree of 20 people and as httplib status object.

DELETE(method, args, kwargs)

Makes a delete request to the same url as GET would

Example
from patchbook import BatchBook
bb = BatchBook('test.batchbook.com', 'API_KEY_XXXX')
(xml, status) = bb.DELETE('people', 1)

Will delete person with id 1 and returns an empty string and status object.

POST(data, ptype, method, args, kwargs)

  • Builds a url in the same way and makes a POST request
  • data(a dictionary) and ptype and used to build the post strings like so: ptype[data.key0]=data.value0&ptype[data.key1]=data.value1
  • If ptype is '' or none the post string will just be urlencoded
  • Posting to a url will add a new entry of the type implied by method.
  • Returns emptry string and status message same as delete

PUT(data, ptype, method, args, kwargs)

  • Builds a url in the same way and makes a PUT request
  • The post string is built the same way.
  • Puting to a url will update an entry of the type implied by method and id in the args.
  • Returns emptry string and status message same as delete

Development by Caktus Consulting Group.