Ported examples over to new config. documented upgrading
This commit is contained in:
parent
02b916d509
commit
dfecc86dd3
17 changed files with 122 additions and 39 deletions
|
|
@ -10,7 +10,9 @@
|
|||
|
||||
~ How do I use it?
|
||||
|
||||
1. edit the configuration in the minitwit.py file
|
||||
1. edit the configuration in the minitwit.py file or
|
||||
export an MINITWIT_SETTINGS environment variable
|
||||
pointing to a configuration file.
|
||||
|
||||
2. fire up a python shell and run this:
|
||||
|
||||
|
|
|
|||
|
|
@ -27,11 +27,13 @@ SECRET_KEY = 'development key'
|
|||
|
||||
# create our little application :)
|
||||
app = Flask(__name__)
|
||||
app.config.from_object(__name__)
|
||||
app.config.from_envvar('MINITWIT_SETTINGS', silent=True)
|
||||
|
||||
|
||||
def connect_db():
|
||||
"""Returns a new connection to the database."""
|
||||
return sqlite3.connect(DATABASE)
|
||||
return sqlite3.connect(app.config['DATABASE'])
|
||||
|
||||
|
||||
def init_db():
|
||||
|
|
@ -237,12 +239,9 @@ def logout():
|
|||
return redirect(url_for('public_timeline'))
|
||||
|
||||
|
||||
# add some filters to jinja and set the secret key and debug mode
|
||||
# from the configuration.
|
||||
# add some filters to jinja
|
||||
app.jinja_env.filters['datetimeformat'] = format_datetime
|
||||
app.jinja_env.filters['gravatar'] = gravatar_url
|
||||
app.secret_key = SECRET_KEY
|
||||
app.debug = DEBUG
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
|
|
@ -18,14 +18,14 @@ class MiniTwitTestCase(unittest.TestCase):
|
|||
|
||||
def setUp(self):
|
||||
"""Before each test, set up a blank database"""
|
||||
self.db_fd, minitwit.DATABASE = tempfile.mkstemp()
|
||||
self.db_fd, minitwit.app.config['DATABASE'] = tempfile.mkstemp()
|
||||
self.app = minitwit.app.test_client()
|
||||
minitwit.init_db()
|
||||
|
||||
def tearDown(self):
|
||||
"""Get rid of the database again after each test."""
|
||||
os.close(self.db_fd)
|
||||
os.unlink(minitwit.DATABASE)
|
||||
os.unlink(minitwit.app.config['DATABASE'])
|
||||
|
||||
# helper functions
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue