[r4327]: trunk / tg / commands / migration.py Maximize Restore History

Download this file

migration.py    39 lines (30 with data), 1.1 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""
TurboGears migration
"""
from paste.script import command
import os
import ConfigParser
from migrate.versioning.shell import main
class MigrateCommand(command.Command):
"""Sqlalchemy migration"""
max_args = 3
min_args = 1
summary = __doc__.splitlines()[0]
usage = '\n' + __doc__
group_name = "TurboGears2"
parser = command.Command.standard_parser(verbose=True)
def command(self):
ini = 'development.ini'
sect = 'app:main'
option = 'sqlalchemy.url'
# get sqlalchemy.url config in app:mains
curdir = os.getcwd()
conf = ConfigParser.ConfigParser()
conf.read(os.path.join(curdir, ini))
self.name = "migration"
try:
self.dburi = conf.get(sect, option, vars={'here':curdir})
except:
print "you shold set sqlalchemy.url in development.ini first"
print "The repository is %s\nThe dburi is in %s"%(self.name, self.dburi)
main(argv=self.args, url=self.dburi,repository=self.name, name=self.name)