Parent: [2b22bf] (diff)

Child: [07d27c] (diff)

Download this file

bootstrap.py    54 lines (49 with data), 1.6 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# -*- coding: utf-8 -*-
"""Setup the pyforge application"""
import sys
import logging
from tg import config
from pylons import c
from pyforge import model as M
log = logging.getLogger(__name__)
def bootstrap(command, conf, vars):
"""Place any commands to setup pyforge here"""
dburi='mongo://localhost:27017/project:test'
database='project:test'
M.User.m.remove({})
M.Project.m.remove({})
u0 = M.User.make(dict(username='test_admin', display_name='Test Admin'))
u1 = M.User.make(dict(username='test_user', display_name='Test User'))
u0.set_password('foo')
u1.set_password('foo')
u0.m.save()
u1.m.save()
p0 = M.Project.make(dict(_id='test/', database=database, is_root=True))
p0.allow_user(u0, 'create', 'read', 'delete', 'plugin', 'security')
p0.allow_user(u1, 'read')
p1 = p0.new_subproject('sub1')
p0.m.save()
p1.m.save()
c.project = p0
c.user = u0
M.AppConfig.m.remove({})
p0.uninstall_app('hello_forge')
p0.install_app('hello_forge')
def pm(etype, value, tb):
import pdb, traceback
try:
from IPython.ipapi import make_session; make_session()
from IPython.Debugger import Pdb
sys.stderr.write('Entering post-mortem IPDB shell\n')
p = Pdb(color_scheme='Linux')
p.reset()
p.setup(None, tb)
p.print_stack_trace()
p.cmdloop()
p.forget()
# p.interaction(None, tb)
except ImportError:
sys.stderr.write('Entering post-mortem PDB shell\n')
traceback.print_exception(etype, value, tb)
pdb.post_mortem(tb)
sys.excepthook = pm