Ejemplo n.º 1
0
 def __call__(self, environ, start_response):
     """Invoke the Controller"""
     # WSGIController.__call__ dispatches to the Controller method
     # the request is routed to. This routing information is
     # available in environ['pylons.routes_dict']
     try:
         return WSGIController.__call__(self, environ, start_response)
     finally:
         Session.remove()
Ejemplo n.º 2
0
def init_model(engine):
    """Call me before using any of the tables or classes in the model"""
    Session.configure(bind=engine)
Ejemplo n.º 3
0
def create(conf):
    permissions = {}
    groups = []

    # create permissions
    for p in all_perms:
        new_p = Permission(p)
        Session.add(new_p)
        permissions.update({p: new_p})

    for g, perms in default_groups.iteritems():
        new_g = Group(g)
        new_g.protected = True
        for p in perms:
            new_g.permissions.append(permissions[p])
        Session.add(new_g)

    Session.commit()

    admins = Session.query(Group).filter(Group.name == "admins").first()
    # add some users from a file into the db for testing
    # each line of the file should be of the form name,email,dn
    admin_file = conf.global_conf["admin_file"]
    f = open(path.expandvars(admin_file), "r")
    for line in f:
        name, email, dn = line.rstrip("\n").split(",")
        user = model.User(user_name=name, email=email, cert_dn=dn)
        user.suspended = False
        user.deleted = False
        current_time = datetime.utcfromtimestamp(time())
        user.created = current_time
        user.groups.append(admins)
        Session.add(user)
    f.close()
    Session.commit()
Ejemplo n.º 4
0
def init_model(engine):
    """Call me before using any of the tables or classes in the model"""
    Session.configure(bind=engine)
Ejemplo n.º 5
0
def create(conf):
    permissions = {}
    groups = []

    # create permissions
    for p in all_perms:
        new_p = Permission(p)
        Session.add(new_p)
        permissions.update({p: new_p})

    for g, perms in default_groups.iteritems():
        new_g = Group(g)
        new_g.protected = True
        for p in perms:
            new_g.permissions.append(permissions[p])
        Session.add(new_g)

    Session.commit()

    admins = Session.query(Group).filter(Group.name == 'admins').first()
    # add some users from a file into the db for testing
    # each line of the file should be of the form name,email,dn
    admin_file = conf.global_conf['admin_file']
    f = open(path.expandvars(admin_file), 'r')
    for line in f:
        name, email, dn = line.rstrip('\n').split(',')
        user = model.User(user_name=name, email=email, cert_dn=dn)
        user.suspended = False
        user.deleted = False
        current_time = datetime.utcfromtimestamp(time())
        user.created = current_time
        user.groups.append(admins)
        Session.add(user)
    f.close()
    Session.commit()