The object is not properly imported into a bottle structure

advertisements

I'm trying to learn Flask from Instant Flask Web Development book following it step-by-step but I get the error presented below. (It seems to be a problem with circular imports.) The questions are:

Can someone explain what would be the fix and detail the circular imports?

Directory structure:

├── manage.py
├── requirements.txt
└── sched
    ├── __init__.py
    ├── __init__.pyc
    ├── app.py
    ├── app.pyc
    ├── static
    └── templates

manager.py:

from flask.ext.script import Manager
from sched import app

manager = Manager(app)
app.config['DEBUG'] = True

if __name__ == '__main__':
    manager.run()

app.py:

from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello World!'

if __name__ == '__main__':
    app.run()

__init__.py is ampty.

Command line generated error:

$ python manage.py runserver
Traceback (most recent call last):
  File "manage.py", line 8, in <module>
    app.config['DEBUG'] = True
AttributeError: 'module' object has no attribute 'config'


When you do

from sched import app

you are importing the app module. The app object is inside the module. The import you want to use is

from sched.app import app