Esempio n. 1
0
def main(global_config, **settings):
    """ This function returns a WSGI application.
    
    It is usually called by the PasteDeploy framework during 
    ``paster serve``.
    """
    from repoze.bfg.authentication import AuthTktAuthenticationPolicy
    from checking.authorization import RouteAuthorizationPolicy
    from checking.authentication import verifyUser

    if not settings.get("sqlalchemy.url"):
        raise ValueError("No 'sqlalchemy.url' value in application configuration.")
    config = Configurator(settings=settings,
            authentication_policy=AuthTktAuthenticationPolicy("secret",
                callback=verifyUser,
                timeout=30*60, max_age=30*60,
                reissue_time=20*60),
            authorization_policy=RouteAuthorizationPolicy())
    config.hook_zca()
    config.begin()
    setupSqlalchemy(settings)
    setupRoutes(config)
    setupChameleon(config)
    setupi18n(config)
    config.end()

    app = config.make_wsgi_app()
    app = TM(app)

    return app
Esempio n. 2
0
def main(global_config, **settings):
    """ This function returns a WSGI application.
    
    It is usually called by the PasteDeploy framework during 
    ``paster serve``.
    """
    from repoze.bfg.authentication import AuthTktAuthenticationPolicy
    from checking.authorization import RouteAuthorizationPolicy
    from checking.authentication import verifyUser

    if not settings.get("sqlalchemy.url"):
        raise ValueError(
            "No 'sqlalchemy.url' value in application configuration.")
    config = Configurator(settings=settings,
                          authentication_policy=AuthTktAuthenticationPolicy(
                              "secret",
                              callback=verifyUser,
                              timeout=30 * 60,
                              max_age=30 * 60,
                              reissue_time=20 * 60),
                          authorization_policy=RouteAuthorizationPolicy())
    config.hook_zca()
    config.begin()
    setupSqlalchemy(settings)
    setupRoutes(config)
    setupChameleon(config)
    setupi18n(config)
    config.end()

    app = config.make_wsgi_app()
    app = TM(app)

    return app
Esempio n. 3
0
def app(global_config, **settings):
    """ This function returns a WSGI application.
    
    It is usually called by the PasteDeploy framework during 
    ``paster serve``.
    """
    zcml_file = settings.get('configure_zcml', 'configure.zcml')
    db_string = settings.get('db_string')
    if db_string is None:
        raise ValueError("No 'db_string' value in application configuration.")
    initialize_sql(db_string)
    config = Configurator(root_factory=get_root, settings=settings)
    config.begin()
    config.load_zcml(zcml_file)
    config.end()
    # Ugly hack to configure the MapperExtension with the settings.
    removal_extension.path = settings.get('upload_directory')
    
    scheduler = Scheduler()
    # Send out queued mails
    from eportfolio.utilities.mail_delivery import trigger_queued_delivery
    scheduler.add_interval_job(trigger_queued_delivery, seconds=30)
    scheduler.start()
    
    return config.make_wsgi_app()
Esempio n. 4
0
def app(global_config, **settings):
    """ This function returns a WSGI application.
    
    It is usually called by the PasteDeploy framework during 
    ``paster serve``.
    """
    zcml_file = settings.get('configure_zcml', 'configure.zcml')
    db_string = settings.get('db_string')
    if db_string is None:
        raise ValueError("No 'db_string' value in application configuration.")
    initialize_sql(db_string)
    config = Configurator(root_factory=get_root, settings=settings)
    config.begin()
    config.load_zcml(zcml_file)
    config.end()
    # Ugly hack to configure the MapperExtension with the settings.
    removal_extension.path = settings.get('upload_directory')

    scheduler = Scheduler()
    # Send out queued mails
    from eportfolio.utilities.mail_delivery import trigger_queued_delivery
    scheduler.add_interval_job(trigger_queued_delivery, seconds=30)
    scheduler.start()

    return config.make_wsgi_app()
Esempio n. 5
0
def app(global_config, **settings):
    """ This function returns a WSGI application.
    
    It is usually called by the PasteDeploy framework during 
    ``paster serve``.
    """
    names = ('src_path', 'store_url', 'cache_url', 'max_entries', 'database', 'content_dir')
    values = []
    for name in names:
        val = settings.get(name)
        if val is None: 
            raise ValueError("No ’%s’ value in application configuration." % name) 
        values.append(val)
        
    src_path, store_url, cache_url, max_entries, database, content_dir = values
    
    zcml_file = settings.get('configure_zcml', 'configure.zcml')
    config = Configurator(settings=settings, root_factory=ContentRoot(content_dir))
    # use local component registry
    config.hook_zca()
    config.begin()
    config.load_zcml(zcml_file)
    
    register_source(src_path)
    register_store(store_url, cache_url, max_entries=max_entries)
    register_catalog(database)
    config.end()
    
    return config.make_wsgi_app()
Esempio n. 6
0
def app(global_config, **settings):
    """ This function returns a WSGI application.
    
    It is usually called by the PasteDeploy framework during 
    ``paster serve``.
    """
    zcml_file = settings.get('configure_zcml', 'configure.zcml')
    root = Root(settings.get('amqp_host', 'localhost'),
                settings.get('amqp_exchange', EXCHANGE))
    config = Configurator(root_factory=lambda request: root, settings=settings)
    config.begin()
    config.load_zcml(zcml_file)
    config.end()
    if settings.get('debug', None):
        return DebuggedApplication(config.make_wsgi_app(), True)
    else:
        return config.make_wsgi_app()
Esempio n. 7
0
def app(global_config, **settings):
    """ This function returns a WSGI application.
    """
    zcml_file = settings.get('configure_zcml', 'configure.zcml')
    config = Configurator(root_factory=get_root, settings=settings)
    config.begin()
    config.load_zcml(zcml_file)
    config.end()
    return config.make_wsgi_app()
Esempio n. 8
0
def maintenance(global_config, **local_conf):
    config = Configurator()
    config.begin()
    config.add_static_view('static', 'karl.views:static')
    config.add_route(name='maintenance',
                    path='/*url',
                    view=dummy_view,
                    view_renderer='down_for_maintenance.pt')
    config.end()
    return config.make_wsgi_app()
Esempio n. 9
0
def app(global_config, **settings):
    """ This function returns a WSGI application.
    
    It is usually called by the PasteDeploy framework during 
    ``paster serve``.
    """
    config = Configurator()
    config.begin()
    config.add_view(home, renderer="templates/home.pt")
    config.add_view(expense, name='expense', renderer='templates/expense.pt')
    config.end()
    return config.make_wsgi_app()
Esempio n. 10
0
def app(global_config, **settings):
    """ This function returns a WSGI application.

    It is usually called by the PasteDeploy framework during
    ``paster serve``.
    """
    zodb_uri = settings.get('zodb_uri')
    zcml_file = settings.get('configure_zcml', 'configure.zcml')
    if zodb_uri is None:
        raise ValueError("No 'zodb_uri' in application configuration.")

    finder = PersistentApplicationFinder(zodb_uri, appmaker)
    def get_root(request):
        return finder(request.environ)
    config = Configurator(root_factory=get_root, settings=settings)
    config.begin()
    config.load_zcml(zcml_file)
    config.end()
    return config.make_wsgi_app()
Esempio n. 11
0
def mailin_monitor_view(context, request):
    """
    Dispatches to a subapp from repoze.mailin.monitor.  I know this looks kind
    of horrible, but this is the best way I know how to mount another object
    graph onto the root object graph in BFG 1.2.  BFG 1.3 will theoretically
    allow SCRIPT_NAME/PATH_INFO rewriting for routes of the form
    '/some/path/*traverse', making it easier to do this with just a route,
    rather than actually constituting a whole new bfg app just to serve this
    subtree.
    """
    global _mailin_monitor_app
    if _mailin_monitor_app is None:
        # Keep imports local in hopes that this can be removed when BFG 1.3
        # comes out.
        from repoze.bfg.authorization import ACLAuthorizationPolicy
        from repoze.bfg.configuration import Configurator
        from karl.models.mailin_monitor import KarlMailInMonitor
        from karl.security.policy import get_groups
        from repoze.bfg.authentication import RepozeWho1AuthenticationPolicy

        authentication_policy = RepozeWho1AuthenticationPolicy(
            callback=get_groups
        )
        authorization_policy = ACLAuthorizationPolicy()
        config = Configurator(root_factory=KarlMailInMonitor(),
                              authentication_policy=authentication_policy,
                              authorization_policy=authorization_policy)
        config.begin()
        config.load_zcml('repoze.mailin.monitor:configure.zcml')
        config.end()
        _mailin_monitor_app = config.make_wsgi_app()

    # Dispatch to subapp
    import webob
    sub_environ = request.environ.copy()
    sub_environ['SCRIPT_NAME'] = '/%s/%s' % (model_path(context),
                                            request.view_name)
    sub_environ['PATH_INFO'] = '/' + '/'.join(request.subpath)
    sub_request = webob.Request(sub_environ)
    return sub_request.get_response(_mailin_monitor_app)
Esempio n. 12
0
def app(global_config, **settings):
    """ This function returns a repoze.bfg.router.Router object.
    
    It is usually called by the PasteDeploy framework during ``paster serve``.
    """
    db_string = settings.get('db_string')
    if db_string is None:
        raise ValueError("No 'db_string' value in application configuration.")
    initialize_sql(db_string)
    
    # Scheduler to copy recurring invoices
    s = Scheduler()
    # Check every 5 minutes for recurring invoices
    s.add_interval_task(copy_recurring, 300)
    s.start_scheduler()
    
    config = Configurator(root_factory=RootFactory, settings=settings)
    config.begin()
    zcml_file = settings.get('configure_zcml', 'configure.zcml')
    config.load_zcml(zcml_file)
    config.end()
    return config.make_wsgi_app()
Esempio n. 13
0
def wsgi_app(**settings):
  config = Configurator(root_factory=get_root, settings=settings)
  config.load_zcml('configure.zcml')
  return config.make_wsgi_app()
Esempio n. 14
0
def wsgi_app(**settings):
    config = Configurator(root_factory=get_root, settings=settings)
    config.load_zcml("configure.zcml")
    return config.make_wsgi_app()
Esempio n. 15
0
        root_factory=get_root,
        default_permission="view",
        authentication_policy=authentication_policy,
        authorization_policy=authorization_policy,
    )
    config.begin()

    ## Configure views
    config.add_view(unprotected)
    config.add_view(protected, "protected.html", permission="view_protected")
    config.add_view(login, "login.html")
    config.add_view(logout, "logout.html")
    config.end()

    ## Create the app object.
    app = config.make_wsgi_app()

    # Configure the repoze.who middleware:

    ## fake .htpasswd authentication source
    io = StringIO()
    for name, password in [("admin", "admin"), ("user", "user")]:
        io.write("%s:%s\n" % (name, password))
    io.seek(0)

    def cleartext_check(password, hashed):
        return password == hashed

    htpasswd = HTPasswdPlugin(io, cleartext_check)

    ## other plugins
Esempio n. 16
0
        root_factory=get_root,
        default_permission='view',
        authentication_policy=authentication_policy,
        authorization_policy=authorization_policy,
    )
    config.begin()

    ## Configure views
    config.add_view(unprotected)
    config.add_view(protected, 'protected.html', permission='view_protected')
    config.add_view(login, 'login.html')
    config.add_view(logout, 'logout.html')
    config.end()

    ## Create the app object.
    app = config.make_wsgi_app()

    # Configure the repoze.who middleware:

    ## fake .htpasswd authentication source
    io = StringIO()
    for name, password in [('admin', 'admin'), ('user', 'user')]:
        io.write('%s:%s\n' % (name, password))
    io.seek(0)

    def cleartext_check(password, hashed):
        return password == hashed

    htpasswd = HTPasswdPlugin(io, cleartext_check)

    ## other plugins