コード例 #1
0
ファイル: __init__.py プロジェクト: calvinti12/seat-geek
from ferris import plugins

plugins.register('angular', templating=False)

import ferris
import os
from ferris.core import template

template.add_template_path(
    os.path.normpath(os.path.join(
        os.path.dirname(ferris.__file__),
        '../angular-app/templates')),
    'angular')
コード例 #2
0
from ferris import plugins, settings, ndb

plugins.register('service_account')

from plugins.settings import SettingModel


class ServiceAccountSettings(SettingModel):
    _name = 'OAuth2 Service Account'
    _settings_key = 'oauth2_service_account'
    domain = ndb.StringProperty(indexed=False,
                                verbose_name="The Google Apps Domain")
    default_user = ndb.StringProperty(
        indexed=False,
        verbose_name="The email of the user to impersonate by default")
    client_email = ndb.StringProperty(
        indexed=False, verbose_name="*****@*****.**")
    private_key = ndb.TextProperty(verbose_name="PEM Format")


def get_config():
    config = settings.get('oauth2_service_account')
    if not config['private_key'] or not config['client_email'] or not config[
            'domain']:
        raise RuntimeError(
            "OAuth2 Service Account is not configured correctly")
    return config


from oauth2client.client import SignedJwtAssertionCredentials
コード例 #3
0
from ferris import plugins, settings, ndb
import hashlib

plugins.register('service_account')


def get_config():
    config = settings.get('oauth2_service_account')
    if not config['private_key'] or not config['client_email'] or not config['domain']:
        raise RuntimeError("OAuth2 Service Account is not configured correctly")
    return config


from oauth2client.client import SignedJwtAssertionCredentials
from oauth2client.appengine import StorageByKeyName, CredentialsNDBProperty


def build_credentials(scope, user=None):
    """
    Builds service account credentials using the configuration stored in settings
    and masquerading as the provided user.
    """
    config = get_config()

    if not user:
        user = config['default_user']

    if not isinstance(scope, (list, tuple)):
        scope = [scope]

    key = generate_storage_key(config['client_email'], scope, user)
コード例 #4
0
from ferris import plugins, settings
from sqlalchemy import create_engine

plugins.register('sqlalchemy')

db = settings.get('database')
engine = create_engine(db.get('connect_string'), **db.get('args'))
コード例 #5
0
from ferris import plugins

plugins.register('google_directory')

from client import *
import monkey