1
2
3
4
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
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
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
39 self.logging_file_config(config_file)
40
41
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
49 sync_design(wsgiapp.config['couchdb.db'], design_path)
50