Table of Contents

Class: IURLContextFactory ./src/peak/naming/interfaces.py

Obtain a context implementation for a URL scheme

Base Classes   
Interface
Methods   
getURLContext
  getURLContext 
getURLContext (
        parent,
        scheme,
        iface,
        componentName=None,
        **options,
        )

Return a context that can provide iface for scheme URLs

scheme is a URL scheme as defined by RFC 1738. The trailing : should not be included. Per RFC 1738, the '-', '+, and .' characters are allowed. Also per the RFC, any implementation of this interface should use the lowercase form of any scheme name supplied.

This function or method should return a context implementation bound to parent, with name componentName and providing **options. If no context implementation supporting iface can be found, return None.

IURLContextFactory is not normally used as a utility; naming context implementations should use the primary naming.spi.getURLContext() function to obtain URL context providers when needed. But, it is possible to register implementations of this interface under part of the peak.naming.schemes property space, and they will then be used to find a more specific URL context.

For example, if you have a set of schemes foo.bar, foo.baz, and foo.spam, you could register the following in an application configuration file:

            [peak.naming.schemes]
            foo.* = "some.module"

and put this in 'some.module':

            from peak.api import *

            moduleProvides(naming.IURLContextFactory)

            def getURLContext(parent,scheme,iface,componentName,**options):
                # code to pick between 'foo.bar', 'foo.baz', etc. and
                # return a context implementation

Of course, the only reason to do this is if the contexts are created dynamically in some fashion, otherwise it would suffice to register foo.bar, etc. directly in your application's configuration.

Alternately, you could register your context factory under peak.naming.schemes.*, in which case it would be used as a default for any schemes not specifically defined or registered.


Table of Contents

This document was automatically generated on Mon Apr 15 01:11:05 2024 by HappyDoc version 2.1