Exemple #1
0
def assertLocation(adapter, parent):
    """Assert locatable adapters.

    This function asserts that the adapter get location-proxied unless it does
    not provide ILocation itself. Further more the returned locatable adapter
    get its parent set unless its __parent__ attribute is not None.

    see adapter.txt
    """
    # handle none-locatable adapters (A)
    if not ILocation.providedBy(adapter):
        locatable = LocationProxy(adapter)
        locatable.__parent__ = parent
        return locatable

    # handle locatable, parentless adapters (B)
    if adapter.__parent__ is None:
        adapter.__parent__ = parent
        return adapter

    # handle locatable, parentful adapters (C)
    else:
        return adapter
Exemple #2
0
 def _customizeUnprotected(self, adapter, context):
     if (ILocation.providedBy(adapter)
         and adapter.__parent__ is None):
                 adapter.__parent__ = context
     return adapter