Skip to content

Instantly share code, notes, and snippets.

@rfk
Created October 27, 2011 01:10
Show Gist options
  • Save rfk/1318511 to your computer and use it in GitHub Desktop.
Save rfk/1318511 to your computer and use it in GitHub Desktop.
strawman sauropod client API
# 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