Created
October 27, 2011 01:10
-
-
Save rfk/1318511 to your computer and use it in GitHub Desktop.
strawman sauropod client API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Each application has some credentials identifing it | |
# as an authorized application. They are the same for | |
# all requests. | |
store = Sauropod("https://sauropod.mozilla.com", | |
"MY APPLICATION ID", | |
"MY APPLICATION PRIVATE KEY") | |
# You always interact with the store as a particular user. | |
# Provide credentials to start a session. | |
# They might be a BrowserID, a "super-credential", whatever. | |
session = store.start_session("SOME USER CREDENTIALS") | |
# Then the session object provides key/value mapping. | |
# We have two options. | |
# Option 1: magic methods. | |
# Good if we're going simple K/V store semantics. | |
session["mykey"] = "myvalue" | |
print session["mykey"] | |
print session.keys() | |
del session["mykey"] | |
# Option 2: custom methods | |
# Better if we're going to have extra semantics on each operation. | |
# For example, conflict detection. | |
session.set("mykey", "myvalue", if_match="etag") | |
print session.get("mykey") | |
print session.listkeys() | |
session.delete("mykey") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment