Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(48)  |  Call(38)  |  Derive(0)  |  Import(10)
Load a plugin from the named configuration section.

Given a Pyramid Configurator object and the name of a config section,
this function loads the plugin as specified in that section and then
registers it into the Pyramid registry as a utility for each of the
interfaces that it provides.

        def load_and_register(section_name, config, interface=None, registry_name=u""):
    """Load a plugin from the named configuration section.

    Given a Pyramid Configurator object and the name of a config section,
    this function loads the plugin as specified in that section and then
    registers it into the Pyramid registry as a utility for each of the
    interfaces that it provides.
    """
    settings = config.registry.settings
    # Load using the Config object if available, since it's faster.
    # If not then fall back to loading from dotted setting names.
    if "config" in settings:
        plugin = load_from_config(section_name, settings["config"])
    else:
        plugin = load_from_settings(section_name, settings)
    if interface is not None:
        interfaces = [interface]
    else:
        interfaces = providedBy(plugin)
    # Register the plugin for each interface that it provides.
    # Use the Configurators delayed-registration machinery to get
    # conflict-resolution and so-forth for free.
    for interface in interfaces:

        def register(interface=interface):
            config.registry.registerUtility(plugin, interface, registry_name)

        config.action((interface, registry_name), register)
    # And return it for user convenience.
    return plugin
        


src/t/o/tokenserver-HEAD/tokenserver/__init__.py   tokenserver(Download)
 
from mozsvc.config import get_configurator
from mozsvc.plugin import load_and_register, load_from_settings
 
 
 
    # initializes the assignment backend
    load_and_register("tokenserver", config)
 
    # initialize the and browserid backend if it exists
    if "browserid.backend" in settings:
        load_and_register("browserid", config)

src/a/p/appsync-HEAD/appsync/__init__.py   appsync(Download)
 
from mozsvc.config import get_configurator
from mozsvc.plugin import load_and_register
 
from appsync.storage import StorageAuthError, ConnectionError, ServerError
 
    # initializes the storage backend
    load_and_register("storage", config)
 
    # initializes the cache tool
    try:
        load_and_register("cache", config)

src/m/o/mozsvc-0.7/mozsvc/tests/test_plugin.py   mozsvc(Download)
 
from mozsvc.config import Config
from mozsvc.plugin import load_and_register
 
 
        settings = {"config": config}
        config = Configurator(settings=settings)
        plugin = load_and_register("test1", config)
        config.commit()
        self.failUnless(verifyObject(ITest1, plugin))
        }
        config = Configurator(settings=settings)
        plugin = load_and_register("test1", config)
        config.commit()
        self.failUnless(verifyObject(ITest1, plugin))
        }
        config = Configurator(settings=settings)
        plugin1 = load_and_register("test1", config)
        plugin2 = load_and_register("test2", config)
        config.commit()

src/m/o/mozservices-HEAD/mozsvc/tests/test_plugin.py   mozservices(Download)
 
from mozsvc.config import Config
from mozsvc.plugin import load_and_register
 
 
        settings = {"config": config}
        config = Configurator(settings=settings)
        plugin = load_and_register("test1", config)
        config.commit()
        self.failUnless(verifyObject(ITest1, plugin))
        }
        config = Configurator(settings=settings)
        plugin = load_and_register("test1", config)
        config.commit()
        self.failUnless(verifyObject(ITest1, plugin))
        }
        config = Configurator(settings=settings)
        plugin1 = load_and_register("test1", config)
        plugin2 = load_and_register("test2", config)
        config.commit()

src/s/e/server-syncstorage-HEAD/syncstorage/tests/test_sql.py   server-syncstorage(Download)
import threading
 
from mozsvc.plugin import load_and_register
from mozsvc.tests.support import get_test_configurator
 
    def test_no_create(self):
        # Storage with no create_tables option; it should default to false.
        # This should fail because the table is absent
        config = get_test_configurator(__file__, 'tests-nocreate.ini')
        storage = load_and_register("storage", config)
        # This should fail because the table is absent
        config = get_test_configurator(__file__, 'tests-dontcreate.ini')
        storage = load_and_register("storage", config)
        self.assertRaises(BackendError, storage.set_items, _UID, "test", bsos)
 
        # Storage with create_tables explicit set to true.
        # This should succeed because the table gets created.
        config = get_test_configurator(__file__, 'tests-docreate.ini')
        storage = load_and_register("storage", config)
    def test_shard(self):
        # Use a configuration with sharding enabled.
        config = get_test_configurator(__file__, 'tests-shard.ini')
        storage = load_and_register("storage", config)
 

src/t/o/tokenserver-HEAD/tokenserver/tests/test_service.py   tokenserver(Download)
from cornice.tests.support import CatchErrors
from mozsvc.config import load_into_settings
from mozsvc.plugin import load_and_register, load_from_settings
 
from metlog.logging import hook_logger
        self.config.registry['metlog'] = metlog_wrapper.client
        self.config.include("tokenserver")
        load_and_register("tokenserver", self.config)
        self.backend = self.config.registry.getUtility(INodeAssignment)
        wsgiapp = self.config.make_wsgi_app()

src/m/o/mozsvc-0.7/mozsvc/tests/test_partial_disable_metrics.py   mozsvc(Download)
from StringIO import StringIO
from mozsvc.config import Config
from mozsvc.plugin import load_and_register
from pyramid.config import Configurator
from textwrap import dedent
        settings = {"config": config}
        config = Configurator(settings=settings)
        self.plugin = load_and_register("test1", config)
        config.commit()
 

src/m/o/mozservices-HEAD/mozsvc/tests/test_partial_disable_metrics.py   mozservices(Download)
from StringIO import StringIO
from mozsvc.config import Config
from mozsvc.plugin import load_and_register
from pyramid.config import Configurator
from textwrap import dedent
        settings = {"config": config}
        config = Configurator(settings=settings)
        self.plugin = load_and_register("test1", config)
        config.commit()
 

src/t/o/tokenserver-HEAD/tokenserver/tests/test_backend_sql.py   tokenserver(Download)
from pyramid.threadlocal import get_current_registry
from mozsvc.config import load_into_settings
from mozsvc.plugin import load_and_register
 
from tokenserver.assignment import INodeAssignment
        # instantiate the backend to test
        self.config.include("tokenserver")
        load_and_register("tokenserver", self.config)
        self.backend = self.config.registry.getUtility(INodeAssignment)