Exemplo n.º 1
0
#if not APP.debug:
#    APP.logger.addHandler(MAIL_HANDLER)

# Log to stderr as well
STDERR_LOG = logging.StreamHandler(sys.stderr)
STDERR_LOG.setLevel(logging.INFO)
APP.logger.addHandler(STDERR_LOG)

LOG = APP.logger

import ukhra
import ukhra.lib as mmlib
import ukhra.forms as forms
import ukhra.lib.model as model

SESSION = mmlib.create_session(APP.config['DB_URL'])
#mmlib.load_all(SESSION)


def is_authenticated():
    """ Returns whether the user is currently authenticated or not. """
    return hasattr(flask.g, 'fas_user') and flask.g.fas_user is not None


def login_required(function):
    """ Flask decorator to ensure that the user is logged in. """
    @wraps(function)
    def decorated_function(*args, **kwargs):
        ''' Wrapped function actually checking if the user is logged in.
        '''
        if not is_authenticated():
Exemplo n.º 2
0
#!/usr/bin/env python
# These two lines are needed to run on EL6
__requires__ = ['SQLAlchemy >= 0.7', 'jinja2 >= 2.4']
import pkg_resources

from ukhra import APP
from ukhra.default_config import DB_URL
from ukhra.lib import model
import ukhra.lib as mmlib
from redis import Redis
import json
import hashlib
from datetime import datetime

r = Redis()
SESSION = mmlib.create_session(DB_URL)

#Now add a user too.
password = '******' % APP.config.get('PASSWORD_SEED', None)
password = hashlib.sha512(password).hexdigest()
user = model.User(user_name='kdas',email_address='*****@*****.**',display_name='Kushal Das', password=password)
SESSION.add(user)
SESSION.commit()

group = model.Group(group_name='admin',display_name='Admin')
SESSION.add(group)
SESSION.commit()

ugbase = model.UserGroup(user_id=user.id, group_id=group.id)
SESSION.add(ugbase)
SESSION.commit()
Exemplo n.º 3
0
# Log to stderr as well
STDERR_LOG = logging.StreamHandler(sys.stderr)
STDERR_LOG.setLevel(logging.INFO)
APP.logger.addHandler(STDERR_LOG)

LOG = APP.logger


import ukhra
import ukhra.lib as mmlib
import ukhra.forms as forms
import ukhra.lib.model as model


SESSION = mmlib.create_session(APP.config['DB_URL'])
#mmlib.load_all(SESSION)


def is_authenticated():
    """ Returns whether the user is currently authenticated or not. """
    return hasattr(flask.g, 'fas_user') and flask.g.fas_user is not None


def login_required(function):
    """ Flask decorator to ensure that the user is logged in. """
    @wraps(function)
    def decorated_function(*args, **kwargs):
        ''' Wrapped function actually checking if the user is logged in.
        '''
        if not is_authenticated():
Exemplo n.º 4
0
#!/usr/bin/env python
# These two lines are needed to run on EL6
__requires__ = ['SQLAlchemy >= 0.7', 'jinja2 >= 2.4']
import pkg_resources

from ukhra import APP
from ukhra.default_config import DB_URL
from ukhra.lib import model
import ukhra.lib as mmlib
from redis import Redis
import json
import hashlib
from datetime import datetime

r = Redis()
SESSION = mmlib.create_session(DB_URL)

#Now add a user too.
password = '******' % APP.config.get('PASSWORD_SEED', None)
password = hashlib.sha512(password).hexdigest()
user = model.User(user_name='kdas',
                  email_address='*****@*****.**',
                  display_name='Kushal Das',
                  password=password)
SESSION.add(user)
SESSION.commit()

group = model.Group(group_name='admin', display_name='Admin')
SESSION.add(group)
SESSION.commit()