/kai/websetup.py

https://bitbucket.org/bbangert/kai/ · Python · 49 lines · 32 code · 14 blank · 3 comment · 1 complexity · db98e0b1c260b1b67d1dcbe2e750259c MD5 · raw file

  1. """Setup the kai application"""
  2. import logging
  3. from couchdb.design import ViewDefinition
  4. import pylons
  5. import pylons.test
  6. from kai.config.environment import load_environment
  7. from kai.model import Article, Comment, Documentation, Human, Paste, Rating, Snippet, Traceback
  8. from kai.model.generics import all_doc_tags
  9. log = logging.getLogger(__name__)
  10. def sync_db(db):
  11. ViewDefinition.sync_many(db, [
  12. all_doc_tags,
  13. Article.all_months, Article.all_tags, Article.by_month,
  14. Article.by_tag, Article.by_time, Article.by_slug,
  15. Comment.by_time, Comment.comment_count, Comment.by_anytime,
  16. Documentation.by_path, Documentation.ids_for_version,
  17. Documentation.doc_key,
  18. Human.by_displayname, Human.by_email, Human.by_email_token,
  19. Human.by_openid, Human.by_password_token,
  20. Paste.by_author, Paste.by_tag, Paste.all_tags, Paste.by_time,
  21. Paste.by_old_id, Paste.by_tag_time, Paste.by_session_id,
  22. Rating.all_raters,
  23. Snippet.by_date, Snippet.by_author, Snippet.by_slug, Snippet.by_title,
  24. Snippet.by_author_id, Snippet.by_tag, Snippet.all_tags,
  25. Snippet.author_totals,
  26. Traceback.by_uuid, Traceback.by_time, Traceback.by_session_id,
  27. ])
  28. def setup_app(command, conf, vars):
  29. """Place any commands to setup kai here"""
  30. # Don't reload the app if it was loaded under the testing environment
  31. if not pylons.test.pylonsapp:
  32. load_environment(conf.global_conf, conf.local_conf)
  33. server = pylons.config['kai.server']
  34. db = pylons.config['kai.db']
  35. sync_db(db)