rdegges / flask-dynamo

DynamoDB integration for Flask.
http://flask-dynamo.readthedocs.org/en/latest/
The Unlicense
141 stars 36 forks source link

Can't load table configuration without default boto config #4

Open alastair opened 9 years ago

alastair commented 9 years ago

The table configuration for flask-dynamo requires a valid connection to be created - This block of code

app.config['DYNAMO_TABLES'] = [
    Table('users', schema=[HashKey('username')]),
    Table('groups', schema=[HashKey('name')]),
]

Causes the following boto code to create a new connection with no parameters: https://github.com/boto/boto/blob/48c5d178d83bc5f2aa6a8e488396e41b2d867ceb/boto/dynamodb2/table.py#L106

If you have no default credentials in ~/.boto, then this fails with a really cryptic error:

/lib/python2.7/site-packages/boto/auth.pyc in get_auth_handler(host, config, provider, requested_capability)
    973             'No handler was ready to authenticate. %d handlers were checked.'
    974             ' %s '
--> 975             'Check your credentials' % (len(names), str(names)))
    976 
    977     # We select the last ready auth handler that was loaded, to allow users to

NoAuthHandlerFound: No handler was ready to authenticate. 1 handlers were checked. ['HmacAuthV4Handler'] Check your credentials

My expectation is that credentials in the flask configuration would be used for configuration instead of ~/.boto or env variables. This is especially unusual if I have local dynamodb configured - it will still go and make a connection with my live credentials before falling back to using the local database.

dcosson commented 9 years ago

I ran into this issue too. It's kind of a hack but I think it should work by setting something arbitrary like connection="This will get overwritten" in the Table init method. That way boto won't instantiate a new connection, and flask-dynamo patches table.connection to be its own connection later anyway here.

rdegges commented 9 years ago

I'll be updating this later tonight. Been traveling and neglected my issues >< Sorry about that! <333

rdegges commented 9 years ago

Anyone have a good suggestion of how to do this, exactly? I'm trying to think of a clean way to make this happen.

regner commented 9 years ago

Also having this issue right now. Would it be best to offer a sub-classed version of boto.dynamodb2.table.Table?