Trees | Index | Help |
|
---|
Package zope :: Package interface :: Module interface :: Class Specification |
|
object
--+ |SpecificationBasePy
--+ | Specification
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 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)
| |
We, or something we depend on, have changed | |
Does the specification extend the given interface? | |
Query for an attribute description | |
Return an iterator for the interfaces in the specification | |
isImplementedBy(self,
ob)
| |
isImplementedByInstancesOf(self,
cls)
| |
Is the interface the same as or extend the given interface | |
Is the interface implemented by an object | |
subscribe(self,
dependent)
| |
unsubscribe(self,
dependent)
| |
weakref(self,
callback)
| |
Inherited from SpecificationBasePy | |
Do instances of the given class implement the interface? | |
Inherited from object | |
x.__delattr__('name') <==> del x.name | |
x.__getattribute__('name') <==> x.name | |
x.__hash__() <==> hash(x) | |
T.__new__(S, ...) -> a new object with type S, a subtype of T | |
helper for pickle | |
helper for pickle | |
x.__repr__() <==> repr(x) | |
x.__setattr__('name', value) <==> x.name = value | |
x.__str__() <==> str(x) |
Property Summary | |
---|---|
__bases__ |
Class Variable Summary | |
---|---|
Implements |
__implemented__ = <implementedBy zope.interface.interfac...
|
ClassProvides |
__provides__ = <zope.interface.declarations.ClassProvide...
|
Inherited from SpecificationBasePy | |
ClassProvides |
__providedBy__ = <zope.interface.declarations.ClassProvi...
|
Method Details |
---|
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 zope.interface import Interface >>> from 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 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) [] |
isOrExtends(self, interface)Is the interface the same as or extend the given interface Examples:>>> from zope.interface import Interface >>> from 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 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 |
Property Details |
---|
__bases__
|
Class Variable Details |
---|
__implemented__
|
__provides__
|
Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Fri Jun 24 12:01:25 2005 | http://epydoc.sf.net |