-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathbootstrap.py_tmpl
More file actions
82 lines (66 loc) · 2.18 KB
/
bootstrap.py_tmpl
File metadata and controls
82 lines (66 loc) · 2.18 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# -*- coding: utf-8 -*-
"""Setup the {{project}} application"""
{{if sqlalchemy}}
import transaction
{{endif}}
from {{package}} import model
def bootstrap(command, conf, vars):
"""Place any commands to setup {{package}} here"""
# <websetup.bootstrap.before.auth
{{if auth == "sqlalchemy"}}
from sqlalchemy.exc import IntegrityError
try:
u = model.User()
u.user_name = 'manager'
u.display_name = 'Example manager'
u.email_address = 'manager@somedomain.com'
u.password = 'managepass'
model.DBSession.add(u)
g = model.Group()
g.group_name = 'managers'
g.display_name = 'Managers Group'
g.users.append(u)
model.DBSession.add(g)
p = model.Permission()
p.permission_name = 'manage'
p.description = 'This permission gives an administrative right'
p.groups.append(g)
model.DBSession.add(p)
u1 = model.User()
u1.user_name = 'editor'
u1.display_name = 'Example editor'
u1.email_address = 'editor@somedomain.com'
u1.password = 'editpass'
model.DBSession.add(u1)
model.DBSession.flush()
transaction.commit()
except IntegrityError:
print('Warning, there was a problem adding your auth data, '
'it may have already been added:')
import traceback
print(traceback.format_exc())
transaction.abort()
print('Continuing with bootstrapping...')
{{elif auth == "ming"}}
g = model.Group()
g.group_name = 'managers'
g.display_name = 'Managers Group'
p = model.Permission()
p.permission_name = 'manage'
p.description = 'This permission gives an administrative right'
p.groups = [g]
u = model.User()
u.user_name = 'manager'
u.display_name = 'Example manager'
u.email_address = 'manager@somedomain.com'
u.groups = [g]
u.password = 'managepass'
u1 = model.User()
u1.user_name = 'editor'
u1.display_name = 'Example editor'
u1.email_address = 'editor@somedomain.com'
u1.password = 'editpass'
model.DBSession.flush()
model.DBSession.clear()
{{endif}}
# <websetup.bootstrap.after.auth>