Switch to unified view

a/scripts/migrate_project_database.py b/scripts/migrate_project_database.py
...
...
4
import logging
4
import logging
5
5
6
from pylons import c
6
from pylons import c
7
from ming.orm import session
7
from ming.orm import session
8
from allura import model as M
8
from allura import model as M
9
10
log = logging.getLogger(__name__)
9
log = logging.getLogger(__name__)
11
10
12
MONGO_HOME=os.environ.get('MONGO_HOME', '/usr')
11
MONGO_HOME=os.environ.get('MONGO_HOME', '/usr')
13
MONGO_DUMP=os.path.join(MONGO_HOME, 'bin/mongodump')
12
MONGO_DUMP=os.path.join(MONGO_HOME, 'bin/mongodump')
14
MONGO_RESTORE=os.path.join(MONGO_HOME, 'bin/mongorestore')
13
MONGO_RESTORE=os.path.join(MONGO_HOME, 'bin/mongorestore')
...
...
37
        return 2
36
        return 2
38
    if project.database_uri is not None:
37
    if project.database_uri is not None:
39
        log.fatal('Project %s is already migrated to %s', pname, project.database_uri)
38
        log.fatal('Project %s is already migrated to %s', pname, project.database_uri)
40
        print 'Project %s already migrated to %s' % (pname, project.database_uri)
39
        print 'Project %s already migrated to %s' % (pname, project.database_uri)
41
        return 2
40
        return 2
42
    M.ProjectRole.query.update(dict(project_id=None), dict(project_id=c.project._id))
41
    M.ProjectRole.query.update(dict(project_id=None), dict({'$set':dict(project_id=c.project._id)}), multi=True)
43
    conn = M.session.main_doc_session.db.connection
42
    conn = M.session.main_doc_session.db.connection
44
    host = '%s:%s' % (conn.host, conn.port)
43
    host = '%s:%s' % (conn.host, conn.port)
45
    dirname = os.tempnam()
44
    dirname = os.tempnam()
46
    try:
45
    try:
47
        if c.project.database not in databases:
46
        if c.project.database not in databases: