Mercurial > wikked
view manage.py @ 49:fb6ae96756c1
Added unit tests.
Refactored core APIs to make them more testable.
Removed unused stuff like caching the configuration in the SQL database.
Fixed the web bootstrap.
Some cosmetic changes to be PEP8 compliant.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Mon, 28 Jan 2013 23:13:04 -0800 |
parents | 86ee1b696070 |
children | 8167b9b6925a |
line wrap: on
line source
# Configure a simpler log format. from wikked import settings settings.LOG_FORMAT = "[%(levelname)s]: %(message)s" # Create the app and the wiki. from wikked.web import app, wiki from wikked.page import Page, DatabasePage # Create the manager. from flask.ext.script import Manager, prompt, prompt_pass manager = Manager(app) @manager.command def users(): """Lists users of this wiki.""" print "Users:" for user in wiki.auth.getUsers(): print " - " + user.username print "" @manager.command def new_user(): """Generates the entry for a new user so you can copy/paste it in your `.wikirc`. """ username = prompt('Username: ') password = prompt_pass('Password: ') password = app.bcrypt.generate_password_hash(password) print "[users]" print "%s = %s" % (username, password) @manager.command def reset(): """ Re-generates the database and the full-text-search index. """ wiki.db.reset(wiki.getPages(from_db=False, factory=Page.factory)) wiki.index.reset(wiki.getPages()) @manager.command def update(): """ Updates the database and the full-text-search index with any changed/new files. """ wiki.db.update(wiki.getPages(from_db=False, factory=Page.factory)) wiki.index.update(wiki.getPages()) @manager.command def list(): """ Lists page names in the wiki. """ for url in wiki.db.getPageUrls(): print url @manager.command def get(url): """ Gets a page that matches the given URL. """ page = wiki.getPage(url) print page.text if __name__ == "__main__": manager.run()