source: gutenbach-web/websetup.py @ 84ed773

debianmacno-cupsweb
Last change on this file since 84ed773 was 973dd91, checked in by Edward Z. Yang <edwardzyang@…>, 16 years ago

Initial commit.

Signed-off-by: Edward Z. Yang <edwardzyang@…>

  • Property mode set to 100644
File size: 1.3 KB
Line 
1"""Setup the sipbmp3-web application"""
2import logging
3
4import transaction
5from tg import config
6
7from sipbmp3web.config.environment import load_environment
8
9log = logging.getLogger(__name__)
10
11def setup_app(command, conf, vars):
12    """Place any commands to setup sipbmp3web here"""
13    load_environment(conf.global_conf, conf.local_conf)
14    # Load the models
15    from sipbmp3web import model
16    print "Creating tables"
17    model.metadata.create_all(bind=config['pylons.app_globals'].sa_engine)
18
19    u = model.User()
20    u.user_name = u'manager'
21    u.display_name = u'Example manager'
22    u.email_address = u'manager@somedomain.com'
23    u.password = u'managepass'
24
25    model.DBSession.add(u)
26
27    g = model.Group()
28    g.group_name = u'managers'
29    g.display_name = u'Managers Group'
30
31    g.users.append(u)
32
33    model.DBSession.add(g)
34
35    p = model.Permission()
36    p.permission_name = u'manage'
37    p.description = u'This permission give an administrative right to the bearer'
38    p.groups.append(g)
39
40    model.DBSession.add(p)
41
42    u1 = model.User()
43    u1.user_name = u'editor'
44    u1.display_name = u'Example editor'
45    u1.email_address = u'editor@somedomain.com'
46    u1.password = u'editpass'
47
48    model.DBSession.add(u1)
49    model.DBSession.flush()
50
51    transaction.commit()
52    print "Successfully setup"
Note: See TracBrowser for help on using the repository browser.