Back to index

plone3  3.1.7
Functions
plone.browserlayer.utils Namespace Reference

Functions

def register_layer
def unregister_layer
def registered_layers

Function Documentation

def plone.browserlayer.utils.register_layer (   layer,
  name,
  site_manager = None 
)
Register the given layer (an interface) with the given name. If it is
already registered, nothing will be done. If site_manager is not given,
the current site manager will be used.

Definition at line 9 of file utils.py.

00009 
00010 def register_layer(layer, name, site_manager=None):
00011     """Register the given layer (an interface) with the given name. If it is
00012     already registered, nothing will be done. If site_manager is not given,
00013     the current site manager will be used.
00014     """
00015     
00016     existing = queryUtility(ILocalBrowserLayerType, name=name)
00017     if existing is not None:
00018         return
00019     
00020     if site_manager is None:
00021         site_manager = getSiteManager()
00022     
00023     if not ILocalBrowserLayerType.providedBy(layer):
00024         alsoProvides(layer, ILocalBrowserLayerType)
00025     
00026     site_manager.registerUtility(component=layer, 
00027                                  provided=ILocalBrowserLayerType, 
00028                                  name=name)
    

Here is the caller graph for this function:

Return all currently registered layers

Definition at line 45 of file utils.py.

00045 
00046 def registered_layers():
00047     """Return all currently registered layers
00048     """
00049     return getAllUtilitiesRegisteredFor(ILocalBrowserLayerType)
def plone.browserlayer.utils.unregister_layer (   name,
  site_manager = None 
)
Unregister the layer with the given name. If it cannot be found, a
KeyError is raised.

Definition at line 29 of file utils.py.

00029 
00030 def unregister_layer(name, site_manager=None):
00031     """Unregister the layer with the given name. If it cannot be found, a
00032     KeyError is raised.
00033     """
00034     
00035     existing = queryUtility(ILocalBrowserLayerType, name=name)
00036     if existing is None:
00037         raise KeyError("No browser layer with name %s is registered." % name)
00038     
00039     if site_manager is None:
00040         site_manager = getSiteManager()
00041         
00042     site_manager.unregisterUtility(component=existing,
00043                                    provided=ILocalBrowserLayerType,
00044                                    name=name)
    

Here is the caller graph for this function: