Provide location information for location objects
There are no attributes in this class.
getName()
Get a location name
See IPhysicallyLocatable.
>>> o1 = Location(); o1.__name__ = 'o1' >>> LocationPhysicallyLocatable(o1).getName() 'o1'
getNearestSite()
return the nearest site, see IPhysicallyLocatable
>>> o1 = Location() >>> o1.__name__ = 'o1' >>> LocationPhysicallyLocatable(o1).getNearestSite() Traceback (most recent call last): ... TypeError: Not enough context information to get all parents
>>> root = Location() >>> zope.interface.directlyProvides(root, IContainmentRoot) >>> o1 = Location() >>> o1.__name__ = 'o1' >>> o1.__parent__ = root >>> LocationPhysicallyLocatable(o1).getNearestSite() is root 1
getPath()
Get the path of a location.
See IPhysicallyLocatable
This is an "absolute path", rooted at a root object.
>>> root = Location() >>> zope.interface.directlyProvides(root, IContainmentRoot) >>> LocationPhysicallyLocatable(root).getPath() u'/'
>>> o1 = Location(); o1.__parent__ = root; o1.__name__ = 'o1' >>> LocationPhysicallyLocatable(o1).getPath() u'/o1'
>>> o2 = Location(); o2.__parent__ = o1; o2.__name__ = u'o2' >>> LocationPhysicallyLocatable(o2).getPath() u'/o1/o2'
It is an error to get the path of a rootless location:
>>> o1.__parent__ = None >>> LocationPhysicallyLocatable(o1).getPath() Traceback (most recent call last): ... TypeError: Not enough context to determine location root
>>> LocationPhysicallyLocatable(o2).getPath() Traceback (most recent call last): ... TypeError: Not enough context to determine location root
If we screw up and create a location cycle, it will be caught:
>>> o1.__parent__ = o2 >>> LocationPhysicallyLocatable(o1).getPath() Traceback (most recent call last): ... TypeError: Maximum location depth exceeded, probably due to a a location cycle.
getRoot()
Get the root location for a location.
See IPhysicallyLocatable
The root location is a location that contains the given location and that implements IContainmentRoot.
>>> root = Location() >>> zope.interface.directlyProvides(root, IContainmentRoot) >>> LocationPhysicallyLocatable(root).getRoot() is root 1
>>> o1 = Location(); o1.__parent__ = root >>> LocationPhysicallyLocatable(o1).getRoot() is root 1
>>> o2 = Location(); o2.__parent__ = o1 >>> LocationPhysicallyLocatable(o2).getRoot() is root 1
We'll get a TypeError if we try to get the location fo a rootless object:
>>> o1.__parent__ = None >>> LocationPhysicallyLocatable(o1).getRoot() Traceback (most recent call last): ... TypeError: Not enough context to determine location root >>> LocationPhysicallyLocatable(o2).getRoot() Traceback (most recent call last): ... TypeError: Not enough context to determine location root
If we screw up and create a location cycle, it will be caught:
>>> o1.__parent__ = o2 >>> LocationPhysicallyLocatable(o1).getRoot() Traceback (most recent call last): ... TypeError: Maximum location depth exceeded, probably due to a a location cycle.
There are no known subclasses.