Пример #1
0
    %(message)s
'''))
mail_handler.setLevel(logging.ERROR)
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 pkgdb2.lib as pkgdblib

SESSION = pkgdblib.create_session(APP.config['DB_URL'])


def is_pkgdb_admin(user):
    """ Is the user a pkgdb admin.
    """
    if not user:
        return False
    if not user.cla_done or len(user.groups) < 1:
        return False

    admins = APP.config['ADMIN_GROUP']
    if isinstance(admins, basestring):
        admins = [admins]
    admins = set(admins)
Пример #2
0
        mail_admin=APP.config.get('MAIL_ADMIN', '*****@*****.**')
    ))

# 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 pkgdb2.lib as pkgdblib
import pkgdb2.proxy

APP.wsgi_app = pkgdb2.proxy.ReverseProxied(APP.wsgi_app)

SESSION = pkgdblib.create_session(APP.config['DB_URL'])


def _monkey_patch_jsonify_jsonp():
    """ Monkey patch Flask's "jsonify" to also handle JSONP

    This makes it so that all API endpoints that return JSON data can now also
    return JSONP data.  This is used specifically by some of our apps that want
    to make ajax calls from one app to pkgdb for more information.
    """

    original_jsonify = flask.jsonify

    def _jsonify_with_jsonp(*args, **kwargs):
        response = original_jsonify(*args, **kwargs)