Module Bastion :: Class BastionClass
[hide private]
[frames] | no frames]

_ClassType BastionClass

Helper class used by the Bastion() function.

You could subclass this and pass the subclass as the bastionclass argument to the Bastion() function, as long as the constructor has the same signature (a get() function and a name for the object).

Instance Methods [hide private]
 
__init__(self, get, name)
Constructor.
 
__repr__(self)
Return a representation string.
 
__getattr__(self, name)
Get an as-yet undefined attribute value.
Method Details [hide private]

__init__(self, get, name)
(Constructor)

 
Constructor.

Arguments:

get - a function that gets the attribute value (by name)
name - a human-readable name for the original object
       (suggestion: use repr(object))

__repr__(self)
(Representation operator)

 

Return a representation string.

This includes the name passed in to the constructor, so that if you print the bastion during debugging, at least you have some idea of what it is.

__getattr__(self, name)
(Qualification operator)

 

Get an as-yet undefined attribute value.

This calls the get() function that was passed to the constructor. The result is stored as an instance variable so that the next time the same attribute is requested, __getattr__() won't be invoked.

If the get() function raises an exception, this is simply passed on -- exceptions are not cached.