Type Specification
object --+
|
SpecificationBasePy --+
|
Specification
- Known Subclasses:
-
Declaration,
InterfaceClass
Specifications
An interface specification is used to track interface declarations and
component registrations.
This class is a base class for both interfaces themselves and for
interface specifications (declarations).
Specifications are mutable. If you reassign their cases, their
relations with other specifications are adjusted accordingly.
For example:
>>> from gnue.navigator.external.zope.interface import Interface
>>> class I1(Interface):
... pass
>>> class I2(I1):
... pass
>>> class I3(I2):
... pass
>>> [i.__name__ for i in I1.__bases__]
['Interface']
>>> [i.__name__ for i in I2.__bases__]
['I1']
>>> I3.extends(I1)
1
>>> I2.__bases__ = (Interface, )
>>> [i.__name__ for i in I2.__bases__]
['Interface']
>>> I3.extends(I1)
0
| Method Summary |
| |
__init__(self,
bases)
|
| |
__setBases(self,
bases)
|
| |
changed(self)
We, or something we depend on, have changed |
| |
extends(self,
interface,
strict)
Does the specification extend the given interface? |
| |
get(self,
name,
default)
Query for an attribute description |
| |
interfaces(self)
Return an iterator for the interfaces in the specification |
| |
isImplementedBy(self,
ob)
|
| |
isImplementedByInstancesOf(self,
cls)
|
| |
isOrExtends(self,
interface)
Is the interface the same as or extend the given interface |
| |
providedBy(self,
ob)
Is the interface implemented by an object |
| |
subscribe(self,
dependent)
|
| |
unsubscribe(self,
dependent)
|
| |
weakref(self,
callback)
|
| Inherited from SpecificationBasePy |
| |
implementedBy(self,
cls)
Test whether the specification is implemented by a class or
factory. |
| Inherited from object |
| |
__delattr__(...)
x.__delattr__('name') <==> del x.name |
| |
__getattribute__(...)
x.__getattribute__('name') <==> x.name |
| |
__hash__(x)
Return hash(x)... |
| |
__new__(T,
S,
...)
Return a new object with type S, a subtype of T... |
| |
__reduce__(...)
helper for pickle |
| |
__reduce_ex__(...)
helper for pickle |
| |
__repr__(x)
Return repr(x)... |
| |
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value |
| |
__str__(x)
Return str(x)... |
| Class Variable Summary |
Implements |
__implemented__ = <implementedBy gnue.navigator.external...
|
ClassProvides |
__provides__ = <gnue.navigator.external.zope.interface.d...
|
| Inherited from SpecificationBasePy |
ClassProvides |
__providedBy__ = <gnue.navigator.external.zope.interface...
|
changed(self)
We, or something we depend on, have changed
-
|
extends(self,
interface,
strict=True)
Does the specification extend the given interface?
Test whether an interface in the specification extends the given
interface
Examples:
>>> from gnue.navigator.external.zope.interface import Interface
>>> from gnue.navigator.external.zope.interface.declarations import Declaration
>>> class I1(Interface): pass
...
>>> class I2(I1): pass
...
>>> class I3(Interface): pass
...
>>> class I4(I3): pass
...
>>> spec = Declaration()
>>> int(spec.extends(Interface))
0
>>> spec = Declaration(I2)
>>> int(spec.extends(Interface))
1
>>> int(spec.extends(I1))
1
>>> int(spec.extends(I2))
1
>>> int(spec.extends(I3))
0
>>> int(spec.extends(I4))
0
>>> I2.extends(I2)
0
>>> I2.extends(I2, False)
1
>>> I2.extends(I2, strict=False)
1
-
|
get(self,
name,
default=None)
Query for an attribute description
-
|
interfaces(self)
Return an iterator for the interfaces in the specification
for example:
>>> from gnue.navigator.external.zope.interface import Interface
>>> class I1(Interface): pass
...
>>> class I2(I1): pass
...
>>> class I3(Interface): pass
...
>>> class I4(I3): pass
...
>>> spec = Specification((I2, I3))
>>> spec = Specification((I4, spec))
>>> i = spec.interfaces()
>>> i.next().getName()
'I4'
>>> i.next().getName()
'I2'
>>> i.next().getName()
'I3'
>>> list(i)
[]
-
|
isImplementedBy(self,
ob)
-
|
isImplementedByInstancesOf(self,
cls)
-
|
isOrExtends(self,
interface)
Is the interface the same as or extend the given interface
Examples:
>>> from gnue.navigator.external.zope.interface import Interface
>>> from gnue.navigator.external.zope.interface.declarations import Declaration
>>> class I1(Interface): pass
...
>>> class I2(I1): pass
...
>>> class I3(Interface): pass
...
>>> class I4(I3): pass
...
>>> spec = Declaration()
>>> int(spec.extends(Interface))
0
>>> spec = Declaration(I2)
>>> int(spec.extends(Interface))
1
>>> int(spec.extends(I1))
1
>>> int(spec.extends(I2))
1
>>> int(spec.extends(I3))
0
>>> int(spec.extends(I4))
0
-
|
providedBy(self,
ob)
Is the interface implemented by an object
>>> from gnue.navigator.external.zope.interface import *
>>> class I1(Interface):
... pass
>>> class C(object):
... implements(I1)
>>> c = C()
>>> class X(object):
... pass
>>> x = X()
>>> I1.providedBy(x)
False
>>> I1.providedBy(C)
False
>>> I1.providedBy(c)
True
>>> directlyProvides(x, I1)
>>> I1.providedBy(x)
True
>>> directlyProvides(C, I1)
>>> I1.providedBy(C)
True
-
|
subscribe(self,
dependent)
-
|
unsubscribe(self,
dependent)
-
|
weakref(self,
callback=None)
-
|
__bases__
-
- Get Method:
- unknown--1213270676(...)
- Set Method:
__setBases(self,
bases)
|
__implemented__
-
- Type:
-
Implements
- Value:
<implementedBy gnue.navigator.external.zope.interface.interface.Specif\
ication>
|
|
__provides__
-
- Type:
-
ClassProvides
- Value:
<gnue.navigator.external.zope.interface.declarations.ClassProvides obj\
ect at 0xb7a436cc>
|
|