Package couchdbkit :: Package ext :: Package pylons :: Module commands
[hide private]
[frames] | no frames]

Source Code for Module couchdbkit.ext.pylons.commands

 1  # -*- coding: utf-8 - 
 2  # 
 3  # This file is part of couchdbkit released under the MIT license.  
 4  # See the NOTICE for more information. 
 5   
 6  import os 
 7  from paste.deploy import loadapp 
 8  from paste.script.command import Command 
 9   
10  from .db import sync_design, default_design_path 
11   
12 -class SyncDbCommand(Command):
13 """Syncs the CouchDB views on disk with the database. 14 15 Example:: 16 17 $ paster syncdb my-development.ini 18 19 This will also create the database if it does not exist 20 """ 21 summary = __doc__.splitlines()[0] 22 usage = '\n' + __doc__ 23 24 min_args = 1 25 max_args = 1 26 group_name = 'couchdbkit' 27 default_verbosity = 3 28 parser = Command.standard_parser(simulate=True) 29
30 - def command(self):
31 """Main command to sync db""" 32 config_file = self.args[0] 33 34 config_name = 'config:%s' % config_file 35 here_dir = os.getcwd() 36 37 if not self.options.quiet: 38 # Configure logging from the config file 39 self.logging_file_config(config_file) 40 41 # Load the wsgi app first so that everything is initialized right 42 wsgiapp = loadapp(config_name, relative_to=here_dir) 43 try: 44 design_path = wsgiapp.config['couchdb.design'] 45 except KeyError: 46 design_path = default_design_path(wsgiapp.config) 47 48 # This syncs the main database. 49 sync_design(wsgiapp.config['couchdb.db'], design_path)
50