Gloria’s Thoughts on REST, client data and Python
Very interesting (not new) post by gloriajw at devchix about REST, client data and Python. The post is based on her experience from a specific client assignment and she describes some of the fundamental considerations/decisions made during the project. I find that her juxtaposition of RESTful and non-RESTful communication between client and server very clearly illustrates how transactions and REST is a great fit:
server’s current state: “My current state is fifty boxes of paper clips in inventory.”
client one: “Hi server. Last time I contacted you, you had seventy boxes of paper clips in inventory. I am placing an order for sixty. I will accept a smaller quantity if you have >= forty in inventory. Bye!”
client two: “Hi server. I need twenty boxes of paper clips. I have no clue how many you had in inventory last time I contacted you, and I don’t really care. Fulfill this exact order or cancel it, no exceptions. Smell ya later.”
server: “Received client two’s request. Hi client two, you are properly authenticated, so I’ll look at your state. You want exactly twenty boxes of paper clips. You will make no exceptions. I currently have fifty boxes. I don’t care how many you have, I only care about how many you need. Your order is fulfilled, and I have thirty left. Bye.”
server: “Received client one’s request. Hi client one, you are properly authenticated, so I’ll look at your state. You want sixty boxes of paper clips. You will settle for a minimum of forty. My current state is only thirty in inventory. Your order is not fulfilled, and I have thirty left. Bye.”
Compare this to non-RESTful chatter between client and server:
client two:”Hi server.”server: “Hi client two. You are authenticated, so I’ll continue to talk to you.” (server stores the state of talking to client two, properly authenticated.)
client one:”Hi server.”
server :”Hi client one. You are authenticated, so I’ll continue to talk to you.” (server stores the state of talking to client one, properly authenticated.)
client one:*BOOM* (crashed, blue screen of death, user restarts session once machine reboots)
client two: “server, hook me up with twenty boxes of paper clips.”
client two: *WHOMP* (browser crashes, user restarts browser)
server: “done, server two….hey wait, I can’t respond to you. How strange.”
client one: “Hi server.”
server: “Client one, you just authenticated, and you’re trying to authenticate again? I have to reject your request. Bye.”
client two: “Hi server.”
server: “client two: you have an outstanding transaction, but now your session ID is different. Are you trying to trick me? Get out of here. Bye.”
client two: “Huh? I just loaded, and have no idea what you’re talking about.”
server: “You are in a messed up state. Your authentication is rejected. Call customer support at 1-800-….”
client two: “????”
The very helpful reply from the non-RESTful server is an especially nice twist.
About this entry
You’re currently reading “Gloria’s Thoughts on REST, client data and Python,” an entry on A Contrario
- Published:
- 01.01.08 / 6pm
- Category:
- Uncategorized
No comments
Jump to comment form | comments rss [?] | trackback uri [?]