Ñò ¶TJJc@s±dZdZddkZddkZddklZlZddklZlZddk Z ddk l Z l Z ddk lZhZdefd „ƒYZd efd „ƒYZd „ZeZd „Zd„Zd„Zdd-d„ƒYZd„Zd„Zd„Zdefd„ƒYZeZeiƒZd„Zee_ e e!fZ"d„Z#d„Z$d„Z%de&fd„ƒYZ'e'Z(yddk)Z)Wne*j onXddk)l(Z(dee(fd„ƒYZ+d „Z,d!„Z-d"„Z.d#„Z/d$„Z0d%„Z1d&„Z2d'e&fd(„ƒYZ3e3Z4dd)„Z6eƒZ7yddk)Z)Wne*j on8Xdd*k)lZl2Z2dd+k)l1Z1dd,k)l4Z4e4ƒZ8dS(.sçImplementation of interface declarations There are three flavors of declarations: - Declarations are used to simply name declared interfaces. - ImplementsDeclarations are used to express the interfaces that a class implements (that instances of the class provides). Implements specifications support inheriting interfaces. - ProvidesDeclarations are used to express interfaces directly provided by objects. $Id: declarations.py 72236 2007-01-26 16:50:29Z alga $ trestructuredtextiÿÿÿÿN(tInterfaceClasst Specification(tmergeOrderingstro(t ClassTypet ModuleType(taddClassAdvisort DeclarationcBsSeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z e Z RS(sInterface declarationscGsti|t|ƒƒdS(N(Rt__init__t_normalizeargs(tselft interfaces((sA/usr/lib64/python2.6/site-packages/zope/interface/declarations.pyR -scCs4ti||ƒy |`Wntj onXdS(N(Rtchangedt_v_attrstAttributeError(R toriginally_changed((sA/usr/lib64/python2.6/site-packages/zope/interface/declarations.pyR 0s  cCs |i|ƒo||iƒjS(sJTest whether an interface is 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 = Declaration(I2, I3) >>> spec = Declaration(I4, spec) >>> int(I1 in spec) 0 >>> int(I2 in spec) 1 >>> int(I3 in spec) 1 >>> int(I4 in spec) 1 (textendsR (R t interface((sA/usr/lib64/python2.6/site-packages/zope/interface/declarations.pyt __contains__7scCs |iƒS(s{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 = Declaration(I2, I3) >>> spec = Declaration(I4, spec) >>> i = iter(spec) >>> i.next().getName() 'I4' >>> i.next().getName() 'I2' >>> i.next().getName() 'I3' >>> list(i) [] (R (R ((sA/usr/lib64/python2.6/site-packages/zope/interface/declarations.pyt__iter__RscCs t|iƒS(séReturn an iterator of all included and extended interfaces for example: >>> from zope.interface import Interface >>> class I1(Interface): pass ... >>> class I2(I1): pass ... >>> class I3(Interface): pass ... >>> class I4(I3): pass ... >>> spec = Declaration(I2, I3) >>> spec = Declaration(I4, spec) >>> i = spec.flattened() >>> i.next().getName() 'I4' >>> i.next().getName() 'I2' >>> i.next().getName() 'I1' >>> i.next().getName() 'I3' >>> i.next().getName() 'Interface' >>> list(i) [] (titert__iro__(R ((sA/usr/lib64/python2.6/site-packages/zope/interface/declarations.pyt flattenednscCsntg}|iƒD]P}g}|iƒD]$}|i|dƒo ||q+q+~p ||qq~ŒS(sÎRemove interfaces from a specification Examples: >>> from zope.interface import Interface >>> class I1(Interface): pass ... >>> class I2(I1): pass ... >>> class I3(Interface): pass ... >>> class I4(I3): pass ... >>> spec = Declaration() >>> [iface.getName() for iface in spec] [] >>> spec -= I1 >>> [iface.getName() for iface in spec] [] >>> spec -= Declaration(I1, I2) >>> [iface.getName() for iface in spec] [] >>> spec = Declaration(I2, I4) >>> [iface.getName() for iface in spec] ['I2', 'I4'] >>> [iface.getName() for iface in spec - I4] ['I2'] >>> [iface.getName() for iface in spec - I1] ['I4'] >>> [iface.getName() for iface ... in spec - Declaration(I3, I4)] ['I2'] i(RR R(R tothert_[1]tit_[2]tj((sA/usr/lib64/python2.6/site-packages/zope/interface/declarations.pyt__sub__s$cCs”h}g}x<|iƒD].}||jod||<|i|ƒqqWx<|iƒD].}||jod||<|i|ƒqXqXWt|ŒS(sAdd two specifications or a specification and an interface Examples: >>> from zope.interface import Interface >>> class I1(Interface): pass ... >>> class I2(I1): pass ... >>> class I3(Interface): pass ... >>> class I4(I3): pass ... >>> spec = Declaration() >>> [iface.getName() for iface in spec] [] >>> [iface.getName() for iface in spec+I1] ['I1'] >>> [iface.getName() for iface in I1+spec] ['I1'] >>> spec2 = spec >>> spec += I1 >>> [iface.getName() for iface in spec] ['I1'] >>> [iface.getName() for iface in spec2] [] >>> spec2 += Declaration(I3, I4) >>> [iface.getName() for iface in spec2] ['I3', 'I4'] >>> [iface.getName() for iface in spec+spec2] ['I1', 'I3', 'I4'] >>> [iface.getName() for iface in spec2+spec] ['I3', 'I4', 'I1'] i(R tappendR(R RtseentresultR((sA/usr/lib64/python2.6/site-packages/zope/interface/declarations.pyt__add__ºs%      ( t__name__t __module__t__doc__R R RRRRR!t__radd__(((sA/usr/lib64/python2.6/site-packages/zope/interface/declarations.pyR*s     ! + 2t ImplementscBs,eZdZdZdZd„Zd„ZRS(t?cCs d|iS(Ns(R"(R ((sA/usr/lib64/python2.6/site-packages/zope/interface/declarations.pyt__repr__ÿscCst|iffS(N(t implementedBytinherit(R ((sA/usr/lib64/python2.6/site-packages/zope/interface/declarations.pyt __reduce__sN((R"R#tNoneR*tdeclaredR(R+(((sA/usr/lib64/python2.6/site-packages/zope/interface/declarations.pyR&õs  cCs‡y|iidƒ}Wn}tj oqt|dd ƒ}|d jo&ti|ƒ}|d j o|StS|itjo|St t |fƒŒSXt |tƒo|S|d jo%ti|ƒ}|d j o|Sn|d j o.|f}tt |ƒŒ}d |_ |` n€y |i}Wn9tj o-t|ƒptd|ƒ‚nd }nXtg}|D]}|t|ƒqo~Œ}||_ t|ddƒpddt|ddƒpd|_yr||_ t|dƒp t|_nt |tƒo8d|ijo(t|t|d t|ƒƒƒ|_nWn@tj o4t |tƒptd |ƒ‚n|t|>> from zope.interface import Interface >>> class I1(Interface): pass ... >>> class I2(I1): pass ... >>> class I3(Interface): pass ... >>> class I4(I3): pass ... >>> class C1(object): ... implements(I2) >>> class C2(C1): ... implements(I3) >>> [i.getName() for i in implementedBy(C2)] ['I3', 'I2'] Really, any object should be able to receive a successful answer, even an instance: >>> class Callable(object): ... def __call__(self): ... return self >>> implementedBy(Callable()) Note that the name of the spec ends with a '?', because the `Callable` instance does not have a `__name__` attribute. t__implemented__s$ImplementedBy called for non-factoryR#R't.R"t__providedBy__t __provides__t __class__s!ImplementedBy called for non-typeN((t__dict__tgetRtgetattrR,t#BuiltinImplementationSpecificationst_emptyR2R&RR t isinstanceR*R.t __bases__tcallablet TypeErrorR)R"thasattrtobjectSpecificationDescriptorR0tDescriptorAwareMetaClassest ClassProvidesttypeR1(tclstspectbasesRtc((sA/usr/lib64/python2.6/site-packages/zope/interface/declarations.pytimplementedByFallbacks\&             - 7  &cGs/t|ƒ}d|_d|_t||ŒdS(süDeclare the only interfaces implemented by instances of a class The arguments after the class are one or more interfaces or interface specifications (``IDeclaration`` objects). The interfaces given (including the interfaces in the specifications) replace any previous declarations. Consider the following example: >>> from zope.interface import Interface >>> class I1(Interface): pass ... >>> class I2(Interface): pass ... >>> class I3(Interface): pass ... >>> class I4(Interface): pass ... >>> class A(object): ... implements(I3) >>> class B(object): ... implements(I4) >>> class C(A, B): ... pass >>> classImplementsOnly(C, I1, I2) >>> [i.getName() for i in implementedBy(C)] ['I1', 'I2'] Instances of ``C`` provide only ``I1``, ``I2``, and regardless of whatever interfaces instances of ``A`` and ``B`` implement. N((R)R-R,R*tclassImplements(RAR RB((sA/usr/lib64/python2.6/site-packages/zope/interface/declarations.pytclassImplementsOnlys!   cGsát|ƒ}|itt|ƒƒ7_g}h}x9|iD].}||jod||<|i|ƒq=q=W|idj oOxL|iiD]:}t|ƒ}||jod||<|i|ƒqŒqŒWnt|ƒ|_dS(s¸Declare additional interfaces implemented for instances of a class The arguments after the class are one or more interfaces or interface specifications (``IDeclaration`` objects). The interfaces given (including the interfaces in the specifications) are added to any interfaces previously declared. Consider the following example: >>> from zope.interface import Interface >>> class I1(Interface): pass ... >>> class I2(Interface): pass ... >>> class I3(Interface): pass ... >>> class I4(Interface): pass ... >>> class I5(Interface): pass ... >>> class A(object): ... implements(I3) >>> class B(object): ... implements(I4) >>> class C(A, B): ... pass >>> classImplements(C, I1, I2) >>> [i.getName() for i in implementedBy(C)] ['I1', 'I2', 'I3', 'I4'] >>> classImplements(C, I5) >>> [i.getName() for i in implementedBy(C)] ['I1', 'I2', 'I5', 'I3', 'I4'] Instances of ``C`` provide ``I1``, ``I2``, ``I5``, and whatever interfaces instances of ``A`` and ``B`` provide. iN(R)R-ttupleR RR*R,R9(RAR RBRCRtbRD((sA/usr/lib64/python2.6/site-packages/zope/interface/declarations.pyRF¥s"'        cCs*|id\}}|`|||Œ|S(Nt__implements_advice_data__(R3RJ(RAR RF((sA/usr/lib64/python2.6/site-packages/zope/interface/declarations.pyt_implements_adviceás t implementercBseZd„Zd„ZRS(cGs ||_dS(N(R (R R ((sA/usr/lib64/python2.6/site-packages/zope/interface/declarations.pyR êscCset|tƒotdƒ‚nt|iŒ}y ||_Wn"tj otd|ƒ‚nX|S(NsXCan't use implementer with classes. Use one of the class-declaration functions instead.sCan't declare implements(R8R>R;R&R R.R(R tobRB((sA/usr/lib64/python2.6/site-packages/zope/interface/declarations.pyt__call__ís (R"R#R RN(((sA/usr/lib64/python2.6/site-packages/zope/interface/declarations.pyRLès cCs¢tidƒ}|i}||ijp!d|jo(tid d jot|dƒ‚nd|jot|dƒ‚n||f|d>> from zope.interface import Interface >>> class IA1(Interface): pass ... >>> class IA2(Interface): pass ... >>> class IB(Interface): pass ... >>> class IC(Interface): pass ... >>> class A(object): implements(IA1, IA2) ... >>> class B(object): implements(IB) ... >>> class C(A, B): ... implements(IC) >>> ob = C() >>> int(IA1 in providedBy(ob)) 1 >>> int(IA2 in providedBy(ob)) 1 >>> int(IB in providedBy(ob)) 1 >>> int(IC in providedBy(ob)) 1 Instances of ``C`` implement ``I1``, ``I2``, and whatever interfaces instances of ``A`` and ``B`` implement. t implementsN(RXRF(R ((sA/usr/lib64/python2.6/site-packages/zope/interface/declarations.pyRY s>> from zope.interface import Interface >>> class IA1(Interface): pass ... >>> class IA2(Interface): pass ... >>> class IB(Interface): pass ... >>> class IC(Interface): pass ... >>> class A(object): implements(IA1, IA2) ... >>> class B(object): implements(IB) ... >>> class C(A, B): ... implementsOnly(IC) >>> ob = C() >>> int(IA1 in providedBy(ob)) 0 >>> int(IA2 in providedBy(ob)) 0 >>> int(IB in providedBy(ob)) 0 >>> int(IC in providedBy(ob)) 1 Instances of ``C`` implement ``IC``, regardless of what instances of ``A`` and ``B`` implement. timplementsOnlyN(RXRG(R ((sA/usr/lib64/python2.6/site-packages/zope/interface/declarations.pyRZHs8tProvidescBs/eZdZd„Zd„ZdZd„ZRS(sImplement __provides__, the instance-specific specification When an object is pickled, we pickle the interfaces that it implements. cGs:|f||_||_ti||t|ƒfŒdS(N(t_Provides__argst_clsRR R)(R RAR ((sA/usr/lib64/python2.6/site-packages/zope/interface/declarations.pyR Œs cCs t|ifS(N(R[R\(R ((sA/usr/lib64/python2.6/site-packages/zope/interface/declarations.pyR+‘sszope.interfacecCs2|djo||ijo|Stdƒ‚dS(sÍMake sure that a class __provides__ doesn't leak to an instance For example: >>> from zope.interface import Interface >>> class IFooFactory(Interface): pass ... >>> class C(object): ... pass >>> C.__provides__ = ProvidesClass(C, IFooFactory) >>> [i.getName() for i in C.__provides__] ['IFooFactory'] >>> getattr(C(), '__provides__', 0) 0 R1N(R,R]R(R tinstRA((sA/usr/lib64/python2.6/site-packages/zope/interface/declarations.pyt__get__–s(R"R#R$R R+R_(((sA/usr/lib64/python2.6/site-packages/zope/interface/declarations.pyR[†s   cGs:ti|ƒ}|djot|Œ}|t|>> import gc >>> def collect(): ... for i in range(4): ... gc.collect() ) >>> collect() >>> before = len(InstanceDeclarations) >>> class C(object): ... pass >>> from zope.interface import Interface >>> class I(Interface): ... pass >>> c1 = C() >>> c2 = C() >>> len(InstanceDeclarations) == before 1 >>> directlyProvides(c1, I) >>> len(InstanceDeclarations) == before + 1 1 >>> directlyProvides(c2, I) >>> len(InstanceDeclarations) == before + 1 1 >>> del c1 >>> collect() >>> len(InstanceDeclarations) == before + 1 1 >>> del c2 >>> collect() >>> len(InstanceDeclarations) == before 1 N(tInstanceDeclarationsR4R,t ProvidesClass(R RB((sA/usr/lib64/python2.6/site-packages/zope/interface/declarations.pyR[·s 7  cGsít|ddƒ}|dj o=t|ddƒ|jo$t|tƒptdƒ‚q\nt|ƒ}|djot|ƒ}nt}x)tD]!}t||ƒo t }Pq’q’W|ot |||Œ|_ nt ||Œ|_ dS(s«Declare interfaces declared directly for an object The arguments after the object are one or more interfaces or interface specifications (``IDeclaration`` objects). The interfaces given (including the interfaces in the specifications) replace interfaces previously declared for the object. Consider the following example: >>> from zope.interface import Interface >>> class I1(Interface): pass ... >>> class I2(Interface): pass ... >>> class IA1(Interface): pass ... >>> class IA2(Interface): pass ... >>> class IB(Interface): pass ... >>> class IC(Interface): pass ... >>> class A(object): implements(IA1, IA2) ... >>> class B(object): implements(IB) ... >>> class C(A, B): ... implements(IC) >>> ob = C() >>> directlyProvides(ob, I1, I2) >>> int(I1 in providedBy(ob)) 1 >>> int(I2 in providedBy(ob)) 1 >>> int(IA1 in providedBy(ob)) 1 >>> int(IA2 in providedBy(ob)) 1 >>> int(IB in providedBy(ob)) 1 >>> int(IC in providedBy(ob)) 1 The object, ``ob`` provides ``I1``, ``I2``, and whatever interfaces instances have been declared for instances of ``C``. To remove directly provided interfaces, use ``directlyProvidedBy`` and subtract the unwanted interfaces. For example: >>> directlyProvides(ob, directlyProvidedBy(ob)-I2) >>> int(I1 in providedBy(ob)) 1 >>> int(I2 in providedBy(ob)) 0 removes I2 from the interfaces directly provided by ``ob``. The object, ``ob`` no longer directly provides ``I2``, although it might still provide ``I2`` if it's class implements ``I2``. To add directly provided interfaces, use ``directlyProvidedBy`` and include additional interfaces. For example: >>> int(I2 in providedBy(ob)) 0 >>> directlyProvides(ob, directlyProvidedBy(ob), I2) adds ``I2`` to the interfaces directly provided by ob:: >>> int(I2 in providedBy(ob)) 1 R2sHAttempt to make an interface declaration on a non-descriptor-aware classN( R5R,R8R>R;R R@tFalset issubclasstTrueR?R1R[(tobjectR RAtissubtdamc((sA/usr/lib64/python2.6/site-packages/zope/interface/declarations.pytdirectlyProvidesøs P&   cGst|t|ƒ|ŒdS(s„Declare interfaces declared directly for an object The arguments after the object are one or more interfaces or interface specifications (``IDeclaration`` objects). The interfaces given (including the interfaces in the specifications) are added to the interfaces previously declared for the object. Consider the following example: >>> from zope.interface import Interface >>> class I1(Interface): pass ... >>> class I2(Interface): pass ... >>> class IA1(Interface): pass ... >>> class IA2(Interface): pass ... >>> class IB(Interface): pass ... >>> class IC(Interface): pass ... >>> class A(object): implements(IA1, IA2) ... >>> class B(object): implements(IB) ... >>> class C(A, B): ... implements(IC) >>> ob = C() >>> directlyProvides(ob, I1) >>> int(I1 in providedBy(ob)) 1 >>> int(I2 in providedBy(ob)) 0 >>> int(IA1 in providedBy(ob)) 1 >>> int(IA2 in providedBy(ob)) 1 >>> int(IB in providedBy(ob)) 1 >>> int(IC in providedBy(ob)) 1 >>> alsoProvides(ob, I2) >>> int(I1 in providedBy(ob)) 1 >>> int(I2 in providedBy(ob)) 1 >>> int(IA1 in providedBy(ob)) 1 >>> int(IA2 in providedBy(ob)) 1 >>> int(IB in providedBy(ob)) 1 >>> int(IC in providedBy(ob)) 1 The object, ``ob`` provides ``I1``, ``I2``, and whatever interfaces instances have been declared for instances of ``C``. Notice that the alsoProvides just extends the provided interfaces. N(RhtdirectlyProvidedBy(ReR ((sA/usr/lib64/python2.6/site-packages/zope/interface/declarations.pyt alsoProvides`sAcCs;t|t|ƒ|ƒ|i|ƒotdƒ‚ndS(s: This removes a directly provided interface from an object. Consider the following two interfaces: >>> from zope.interface import Interface >>> class I1(Interface): pass ... >>> class I2(Interface): pass ... ``I1`` is provided through the class, ``I2`` is directly provided by the object: >>> class C(object): ... implements(I1) >>> c = C() >>> alsoProvides(c, I2) >>> I2.providedBy(c) True Remove I2 from c again: >>> noLongerProvides(c, I2) >>> I2.providedBy(c) False Removing an interface that is provided through the class is not possible: >>> noLongerProvides(c, I1) Traceback (most recent call last): ... ValueError: Can only remove directly provided interfaces. s-Can only remove directly provided interfaces.N(RhRit providedByt ValueError(ReR((sA/usr/lib64/python2.6/site-packages/zope/interface/declarations.pytnoLongerProvides£s#tClassProvidesBasePycBseZd„ZRS(cCs:||ijo|djo|S|iStdƒ‚dS(NR1(R]R,RXR(R R^RA((sA/usr/lib64/python2.6/site-packages/zope/interface/declarations.pyR_Ìs  (R"R#R_(((sA/usr/lib64/python2.6/site-packages/zope/interface/declarations.pyRnÊs(tClassProvidesBaseR?cBs)eZdZd„Zd„ZeiZRS(seSpecial descriptor for class __provides__ The descriptor caches the implementedBy info, so that we can get declarations for objects without instance-specific interfaces a bit quicker. For example: >>> from zope.interface import Interface >>> class IFooFactory(Interface): ... pass >>> class IFoo(Interface): ... pass >>> class C(object): ... implements(IFoo) ... classProvides(IFooFactory) >>> [i.getName() for i in C.__provides__] ['IFooFactory'] >>> [i.getName() for i in C().__provides__] ['IFoo'] cGsL||_t|ƒ|_||f||_ti||t|ƒfŒdS(N(R]R)RXt_ClassProvides__argsRR (R RAtmetaclsR ((sA/usr/lib64/python2.6/site-packages/zope/interface/declarations.pyR üs cCs|i|ifS(N(R2Rp(R ((sA/usr/lib64/python2.6/site-packages/zope/interface/declarations.pyR+s(R"R#R$R R+RoR_(((sA/usr/lib64/python2.6/site-packages/zope/interface/declarations.pyR?äs  cCsEt|ddƒ}|djpt|tƒotSt|id ƒS(spReturn the interfaces directly provided by the given object The value returned is an ``IDeclaration``. R1iÿÿÿÿN(R5R,R8R&R7RR9(Retprovides((sA/usr/lib64/python2.6/site-packages/zope/interface/declarations.pyRis  cGs†tidƒ}|i}||ijp d|jotdƒ‚nd|jotdƒ‚nt|ƒ|d>> from zope.interface import Interface >>> class IFoo(Interface): pass ... >>> class IFooFactory(Interface): pass ... >>> class C(object): ... implements(IFoo) ... classProvides(IFooFactory) >>> [i.getName() for i in C.__providedBy__] ['IFooFactory'] >>> [i.getName() for i in C().__providedBy__] ['IFoo'] if equivalent to: >>> from zope.interface import Interface >>> class IFoo(Interface): pass ... >>> class IFooFactory(Interface): pass ... >>> class C(object): ... implements(IFoo) >>> directlyProvides(C, IFooFactory) >>> [i.getName() for i in C.__providedBy__] ['IFooFactory'] >>> [i.getName() for i in C().__providedBy__] ['IFoo'] If classProvides is called outside of a class definition, it fails. >>> classProvides(IFooFactory) Traceback (most recent call last): ... TypeError: classProvides can be used only from a class definition. iR#s7classProvides can be used only from a class definition.R1s:classProvides can only be used once in a class definition.ROiN(RPRQRRRSR;R Rt_classProvides_advice(R RVRW((sA/usr/lib64/python2.6/site-packages/zope/interface/declarations.pyt classProvidessB   cCs$|id}|`t||Œ|S(NR1(R3R1Rh(RAR ((sA/usr/lib64/python2.6/site-packages/zope/interface/declarations.pyRsks  cGstidƒ}|i}||ij p d|jotdƒ‚nd|jotdƒ‚nttt|ƒŒ|d>> from zope.interface import Interface >>> class I1(Interface): pass ... >>> class I2(Interface): pass ... >>> class I3(Interface): pass ... >>> class I31(I3): pass ... >>> class I4(Interface): pass ... >>> class I5(Interface): pass ... >>> class A(object): implements(I1) ... >>> class B(object): __implemented__ = I2 ... >>> class C(A, B): implements(I31) ... >>> c = C() >>> directlyProvides(c, I4) >>> [i.getName() for i in providedBy(c)] ['I4', 'I31', 'I1', 'I2'] >>> [i.getName() for i in providedBy(c).flattened()] ['I4', 'I31', 'I3', 'I1', 'I2', 'Interface'] >>> int(I1 in providedBy(c)) 1 >>> int(I3 in providedBy(c)) 0 >>> int(providedBy(c).extends(I3)) 1 >>> int(providedBy(c).extends(I31)) 1 >>> int(providedBy(c).extends(I5)) 0 >>> class COnly(A, B): implementsOnly(I31) ... >>> class D(COnly): implements(I5) ... >>> c = D() >>> directlyProvides(c, I4) >>> [i.getName() for i in providedBy(c)] ['I4', 'I5', 'I31'] >>> [i.getName() for i in providedBy(c).flattened()] ['I4', 'I5', 'I31', 'I3', 'Interface'] >>> int(I1 in providedBy(c)) 0 >>> int(I3 in providedBy(c)) 0 >>> int(providedBy(c).extends(I3)) 1 >>> int(providedBy(c).extends(I1)) 0 >>> int(providedBy(c).extends(I31)) 1 >>> int(providedBy(c).extends(I5)) 1 (R[(tdirectRA((sA/usr/lib64/python2.6/site-packages/zope/interface/declarations.pytObjectSpecification›sBcCsRt|ddƒ}|dj o|Sy |i}Wntj otSXt|ƒS(NR1(R5R,R2RR7R)(RMRrRA((sA/usr/lib64/python2.6/site-packages/zope/interface/declarations.pytgetObjectSpecificationßs  c Cs¾y |i}Wntj ot|ƒSXy |iWn‚tj ovy |i}Wntj ot|iƒSXy|ii}Wntj o|SX||jot|iƒSnX|S(N(R0RRxRR1R)R2(RMtrtcp((sA/usr/lib64/python2.6/site-packages/zope/interface/declarations.pyRkís$     tObjectSpecificationDescriptorPycBseZdZd„ZRS(s„Implement the `__providedBy__` attribute The `__providedBy__` attribute computes the interfaces peovided by an object. cCsF|djo t|ƒSt|ddƒ}|dj o|St|ƒS(súGet an object specification for an object For example: >>> from zope.interface import Interface >>> class IFoo(Interface): pass ... >>> class IFooFactory(Interface): pass ... >>> class C(object): ... implements(IFoo) ... classProvides(IFooFactory) >>> [i.getName() for i in C.__providedBy__] ['IFooFactory'] >>> [i.getName() for i in C().__providedBy__] ['IFoo'] R1N(R,RxR5R)(R R^RARr((sA/usr/lib64/python2.6/site-packages/zope/interface/declarations.pyR_&s    (R"R#R$R_(((sA/usr/lib64/python2.6/site-packages/zope/interface/declarations.pyR{scCss|djo g}n|i}t|ijpt|ijo|i|ƒnx|D]}t||ƒqXW|S(sËNormalize declaration arguments Normalization arguments might contain Declarions, tuples, or single interfaces. Anything but individial interfaces or implements specs will be expanded. N(R,R2Rt__mro__R&RR (tsequencetoutputRAtv((sA/usr/lib64/python2.6/site-packages/zope/interface/declarations.pyR Js    (R)Rk(Rx(tObjectSpecificationDescriptor((9R$t __docformat__RPtweakreftzope.interface.interfaceRRRRt exceptionsttypesRRtzope.interface.adviceRR6RR&RER)RGRFRKRLRXRYRZR[RatWeakValueDictionaryR`Rdt__safe_for_unpickling__R@R>RhRjRmReRnRot_zope_interface_coptimizationst ImportErrorR?RiRtRsRuRwRxRkR{R€R,R R7R=(((sA/usr/lib64/python2.6/site-packages/zope/interface/declarations.pytsp   Ë x & <   > >+  =   h C '$  Q  * D  2'