Merge pull request #2 from rdegges/master

Allowing Environmental Auth
This commit is contained in:
Kenneth Reitz
2012-07-24 23:35:00 -07:00
2 changed files with 9 additions and 2 deletions
+3
View File
@@ -17,6 +17,9 @@ Usage
table = dynamo.table(TABLE_NAME, (ACCESS_KEY, SECRET_ACCESS_KEY))
# Or, if you have AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY defined as
# environment variables, you can do:
table = dynamo.table(TABLE_NAME)
Writing is simple::
+6 -2
View File
@@ -110,14 +110,18 @@ class Item(object):
return key in self.item
def table(name, auth, eager=True):
def table(name, auth=None, eager=True):
"""Returns a given table for the given user."""
auth = auth or []
dynamodb = boto.connect_dynamodb(*auth)
table = dynamodb.get_table(name)
return Table(table=table, eager=eager)
def tables(auth, eager=True):
def tables(auth=None, eager=True):
"""Returns a list of tables for the given user."""
auth = auth or []
dynamodb = boto.connect_dynamodb(*auth)
return [table(t, auth, eager=eager) for t in dynamodb.list_tables()]