Help - Python REST API (war: Python-list Digest, Vol 183, Issue 13)

dieter dieter at
Fri Dec 14 02:42:48 EST 2018

Afriyie Abraham Kwabena <afriyie.abraham at> writes:
> ...
> Thanks for the reply maybe I did not explain myself very well but is it possible to apply this scenario to a database server like MySQL where I can write some python code to post, get, delete, etc to the database? However the client (python code I have to write ) have to be authenticated and then after that can have access to the data in the server. If this is possible what should be my starting point and which python frameworks or libraries do i have to use to achieve this. 

I have put "Zope" into the ring (for the server side). If your actual
data lives in a relational database, then "Zope" might not be ideal:
while "dm.zope.reseller" demonstrates that "Zope" can be used as an interface
to entities in a relational database, this is not directly supported
and you need some deeper knowledge to get it done.

The particularity of REST is its very limited support for verbs: it knows
only the standard HTTP commands ("GET", "HEAD", "POST", "PUT", "DELETE")
as verbs. You must introduce artificial objects to support a richer
verb set. E.g. to express the verbs "search_users", "add_user",
you would introduce an object "users" and map "search_users --> users/GET",
"add_user --> users/POST"; for "update_user", you would have user objects
representing an individual user and map "update_user --> <user>/PUT".
If you look at this in the relational world, then the object "users"
corresponds to a table, while a user object corresponds to an entry
in this table, i.e. those objects live on different representational
levels (table, table entry) in the relational database.

Out of the box, Zope only has limited support for this kind
of modelization: its "ZSQL Method"s can be used to represent a table;
their "direct traversal" can be used to represent a table entry.
But, you must do special things to get the REST expected semantics
of "POST", "PUT" and "DELETE".

The client side should be easy -- at least, if the number of objects
you must support is small. You can then use the module "urllib2/http.client"
likely together with the module "json".

More information about the Python-list mailing list