question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug in documentation

See original GitHub issue

The example in the documentation contains this:

app.config['DYNAMO_TABLES'] = [
    {
         TableName='users',
         KeySchema=[dict(AttributeName='username', KeyType='HASH')],
         AttributeDefinitions=[dict(AttributeName='username', AttributeType='S')],
         ProvisionedThroughput=dict(ReadCapacityUnits=5, WriteCapacityUnits=5)
    }, {
         TableName='groups',
         KeySchema=[dict(AttributeName='name', KeyType='HASH')],
         AttributeDefinitions=[dict(AttributeName='name', AttributeType='S')],
         ProvisionedThroughput=dict(ReadCapacityUnits=5, WriteCapacityUnits=5)
    }
 ]

Which is invalid syntax, because the keys in the dict are not quoted. A quick fix is to change the braces to dict( ... )

Also, the example endpoint:

@app.route('/create_user')
def create_user():
    dynamo.tables['users'].put_item(data={
        'username': 'rdegges',
        'first_name': 'Randall',
        'last_name': 'Degges',
        'email': 'r@rdegges.com',
    })

…does not work, because the parameter for put_item() should be Item instead of data, and the view should return some valid response instead of None, for example return "", or better jsonify the value returned by put_item().

Although simple to fix, I find these issues worrying, because they are at least 2 years old, and apparently nobody noticed them yet. Is the library maintained?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:2
  • Comments:8

github_iconTop GitHub Comments

12reactions
jldiazcommented, May 28, 2019

@edusantana Yes, of course:

# app.py

from flask import Flask, jsonify
from flask_dynamo import Dynamo

app = Flask(__name__)
app.config['DYNAMO_TABLES'] = [
    dict(
         TableName='users',
         KeySchema=[dict(AttributeName='username', KeyType='HASH')],
         AttributeDefinitions=[dict(AttributeName='username', AttributeType='S')],
         ProvisionedThroughput=dict(ReadCapacityUnits=5, WriteCapacityUnits=5)
    ), 
   dict(
         TableName='groups',
         KeySchema=[dict(AttributeName='name', KeyType='HASH')],
         AttributeDefinitions=[dict(AttributeName='name', AttributeType='S')],
         ProvisionedThroughput=dict(ReadCapacityUnits=5, WriteCapacityUnits=5)
    )
 ]

# ...

@app.route('/create_user')
def create_user():
    r = dynamo.tables['users'].put_item(Item={
        'username': 'rdegges',
        'first_name': 'Randall',
        'last_name': 'Degges',
        'email': 'r@rdegges.com',
    })
   return jsonify(r)
2reactions
rhutkovichcommented, Oct 7, 2019

⚠️ For app factory approach users there is another typo in the doc: Flask.current_app.extensions['dynamodb'] should be flask.current_app.extensions['dynamo']

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation bugs
Bug triaging is the process of reviewing new bugs, verifying whether a bug is valid or not, and gathering more information about it....
Read more >
How to Write A Good Bug Report? Tips and Tricks
Use the following simple Bug report template: · Reporter: Your name and email address. · Product: In which product you found this bug....
Read more >
Common word bugs in software documentation and how to fix ...
Common word bugs in software documentation and how to fix them · Use Correct Words · Go forth and write docs.
Read more >
How to write an Effective Bug Report | BrowserStack
1. Title/Bug ID · 2. Environment · 3. Steps to Reproduce a Bug · 4. Expected Result · 5. Actual Result · 6....
Read more >
Reporting Documentation Bugs - MariaDB Knowledge Base
This page contains general guidelines for the community for reporting documentation bugs. Known Bugs. First, check that the bug isn't already filed in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found