Register a new backend
544577
public function registerBackend(AbstractBackend $backend)
	{
		if (in_array($backend, $this->backends, TRUE)) {
			throw new InvalidArgumentException('Duplicate backend: '.get_class($backend));
		} else {
			$this->backends[] = $backend;

			if ($this->debug_logger) {
				$backend->setDebugLogger($this->debug_logger);
			}
		}
		return $this;
	}
1092736
def _setup_backend(self):
        ''' 
        '''
        self.backends = []
        self.be_poller = zmq.Poller()
        for actual_backend_address in self.backend_address:
            # publisher or client socket
            actual_backend = (actual_backend_address,
                              self.context.socket(self.backend_socket_type))
            # Wait 0.5 s before termating socket
            actual_backend[1].setsockopt(zmq.LINGER, 500)
            # Buffer only 100 meassages, then throw data away
            actual_backend[1].set_hwm(10)
            actual_backend[1].bind(actual_backend_address)
            self.backends.append(actual_backend)
            if self.backend_socket_type != zmq.DEALER:
                self.be_poller.register(actual_backend[1], zmq.POLLIN)
        self.be_stop = threading.Event()
1073377
def _add_backend(self, backend):
        
        md_type = backend.verbose_name
        base = backend().get_model(self)
        # TODO: Rename this field
        new_md_attrs = {'_metadata': self.metadata, '__module__': __name__ }

        new_md_meta = {}
        new_md_meta['verbose_name'] = '%s (%s)' % (self.verbose_name, md_type)
        new_md_meta['verbose_name_plural'] = '%s (%s)' % (self.verbose_name_plural, md_type)
        new_md_meta['unique_together'] = base._meta.unique_together
        new_md_attrs['Meta'] = type("Meta", (), new_md_meta)
        new_md_attrs['_metadata_type'] = backend.name
        model = type("%s%s"%(self.name,"".join(md_type.split())), (base, self.MetadataBaseModel), new_md_attrs.copy())
        self.models[backend.name] = model
        # This is a little dangerous, but because we set __module__ to __name__, the model needs tobe accessible here
        globals()[model.__name__] = model
23179
def load_backend(backend_name):
    
    try:
        if len(backend_name.split(".")) > 1:
            mod = import_module(backend_name)
        else:
            mod = import_module("spamc.backend_%s" % backend_name)
        return mod
    except ImportError:
        error_msg = "%s isn't a spamc backend" % backend_name
        raise ImportError(error_msg)
94057
def get_backend(backend):
    """"""
    if backend == "random":
        backends = list_backends()
        random.shuffle(backends)
        return backends[0]

    return backend
691038
def register_endpoints(self, backend_names):
        
        self.idp_config = self._build_idp_config_endpoints(
            self.config[self.KEY_IDP_CONFIG], backend_names)
        # Create the idp
        idp_config = IdPConfig().load(copy.deepcopy(self.idp_config), metadata_construction=False)
        self.idp = Server(config=idp_config)
        return self._register_endpoints(backend_names)
251684
def add(ctx, alias, mapping, backend):
    
    if not backend:
        backends_list = ctx.obj['settings'].get_backends()
        if len(backends_list) > 1:
            raise click.UsageError(
                "You're using more than 1 backend. Please set the backend to "
                "add the alias to with the --backend option (choices are %s)" %
                ", ".join(dict(backends_list).keys())
            )

    add_mapping(ctx, alias, mapping, backend)
352573
def _init_backends(self, config):
        
        self.backends_params = {}
        self.backends = {}
        self.backends_display_names = {}
        for entry in config['backends']:
            # split at the first dot
            backend, sep, param = entry.partition('.')
            value = config['backends'][entry]
            if backend not in self.backends_params:
                self.backends_params[backend] = {}
            self.backends_params[backend][param] = value
        for backend in self.backends_params:
            # get the backend display_name
            try:
                self.backends_display_names[backend] = \
                    self.backends_params[backend]['display_name']
            except Exception as e:
                self.backends_display_names[backend] = backend
                self.backends_params[backend]['display_name'] = backend
            params = self.backends_params[backend]
            # Loading the backend module
            try:
                module = params['module']
            except Exception as e:
                raise MissingParameter('backends', backend + '.module')
            try:
                bc = __import__(module, globals(), locals(), ['Backend'], 0)
            except Exception as e:
                self._handle_exception(e)
                raise BackendModuleLoadingFail(module)
            try:
                attrslist = self.attributes.get_backend_attributes(backend)
                key = self.attributes.get_backend_key(backend)
                self.backends[backend] = bc.Backend(
                    params,
                    cherrypy.log.error,
                    backend,
                    attrslist,
                    key,
                    )
            except MissingParameter as e:
                raise
            except Exception as e:
                self._handle_exception(e)
                raise BackendModuleInitFail(module)
1210755
private function initializeBackEnd()
    {
        $backEndUser =
            \Tx_Oelib_BackEndLoginManager::getInstance()->getLoggedInUser(\Tx_Oelib_Mapper_BackEndUser::class);
        $this->languageKey = $backEndUser->getLanguage();
    }
171351
def list_backends(_):
    """"""
    backends = [b.__name__ for b in available_backends()]
    print('\n'.join(backends))
412133
public function register()
	{
		// Register the package.
		$this->package('hisorange/bbcoder', 'bbcoder');

		// Register package's config namespace.
        $this->app['config']->package('hisorange/bbcoder', dirname(dirname(dirname(__DIR__))).'/config');

		// Register 'bbcoder'.
		$this->app['bbcoder'] = $this->app->share(function ($app) {
			return new BBCoder($app['config']);
		});

		// Shortcut so developers don't need to add an Alias in app/config/app.php
        $this->app->booting(function() {
            $loader = AliasLoader::getInstance();
            $loader->alias('BBCoder', 'hisorange\bbcoder\Facades\BBCoder');
        });
	}
396591
def register():
    """"""
    if not plim:
        logger.warning('`slim` failed to load dependency `plim`. '
                       '`slim` plugin not loaded.')
        return
    if not mako:
        logger.warning('`slim` failed to load dependency `mako`. '
                       '`slim` plugin not loaded.')
        return
    if not bs:
        logger.warning('`slim` failed to load dependency `BeautifulSoup4`. '
                       '`slim` plugin not loaded.')
        return
    if not minify:
        logger.warning('`slim` failed to load dependency `htmlmin`. '
                       '`slim` plugin not loaded.')
        return

    signals.get_writer.connect(get_writer)
659580
def register_app(app):
    "  "

    from .views import users
    app.register_blueprint(users)

    from .oauth import config_oauth
    config_oauth(app)
1317392
def update_backends(cls, id_mapping, custom_trees, backend=None):
        
        backend = Store.current_backend if backend is None else backend
        # Update the custom option entries for the current backend
        Store.custom_options(backend=backend).update(custom_trees)

        # Propagate option ids for non-selected backends
        for b in Store.loaded_backends():
            if b == backend:
                continue
            backend_trees = Store._custom_options[b]
            for (old_id, new_id) in id_mapping:
                tree = backend_trees.get(old_id, None)
                if tree is not None:
                    backend_trees[new_id] = tree
248907
def _load_backend(self, backend_uri, context):
        
        parsed = parse.urlparse(backend_uri)
        options = dict(parse.parse_qsl(parsed.query))

        try:
            backend = self._entry_points[self.BACKENDS_ENTRY_POINT][parsed.scheme].load()
        except KeyError:
            raise BackendNotFoundError(
                "The requested backend `%s` could not be found in the "
                "registered entry points. Perhaps you forgot to install the "
                "corresponding backend package?" % parsed.scheme
            )

        password = (parse.unquote(parsed.password)
                    if parsed.password
                    else parsed.password)

        return backend(
            username=parsed.username, password=password,
            hostname=parsed.hostname, port=parsed.port,
            path=parsed.path, options=options, context=context,
        )
441471
def build(options = {})
      @stack.reverse.inject(nil) do |backend, (klass, opts)|
        klass.new backend, @options.merge(opts).merge(options)
      end
    end
873843
def register(name, mod, options)
      elements[name] = plugin_type.new(mod, options)
    end