<s> from pyramid . config import Configurator <EOL> from pyramid . events import subscriber , ApplicationCreated <EOL> from couchdbkit import * <EOL> import logging <EOL> log = logging . getLogger ( __name__ ) <EOL> @ subscriber ( ApplicationCreated ) <EOL> def application_created_subscriber ( event ) : <EOL> registry = event . app . registry <EOL> db = registry . db . get_or_create_db ( registry . settings [ '<STR_LIT>' ] ) <EOL> pages_view_exists = db . doc_exist ( '<STR_LIT>' ) <EOL> if pages_view_exists == False : <EOL> design_doc = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : '''<STR_LIT>''' <EOL> } <EOL> } <EOL> } <EOL> db . save_doc ( design_doc ) <EOL> def main ( global_config , ** settings ) : <EOL> """<STR_LIT>""" <EOL> config = Configurator ( settings = settings ) <EOL> config . registry . db = Server ( uri = settings [ '<STR_LIT>' ] ) <EOL> def add_couchdb ( request ) : <EOL> db = config . registry . db . get_db ( settings [ '<STR_LIT>' ] ) <EOL> return db <EOL> config . add_request_method ( add_couchdb , '<STR_LIT>' , reify = True ) <EOL> config . add_static_view ( '<STR_LIT>' , '<STR_LIT>' , cache_max_age = <NUM_LIT> ) <EOL> config . add_route ( '<STR_LIT>' , '<STR_LIT:/>' ) <EOL> config . scan ( ) <EOL> return config . make_wsgi_app ( ) </s>
