Trees | Index | Help |
|
---|
Package p6 :: Package zcmlsupport :: Module interface |
|
Interface utility functions
$Id: interface.py,v 1.1.1.1 2005/04/28 14:49:16 nyergler Exp $
Function Summary | |
---|---|
return interface or ComponentLookupError | |
getInterfaceAllDocs(interface)
| |
interfaceToName(context,
interface)
| |
nameToInterface(context,
id)
| |
register Interface with global site manager as utility | |
return interface or None | |
Interfaces search | |
Interfaces search | |
searchInterfaceUtilities(context,
search_string,
base)
|
Function Details |
---|
getInterface(context, id)return interface or ComponentLookupError >>> from zope.app.testing import placelesssetup >>> placelesssetup.setUp() >>> from zope.interface import Interface >>> from zope.app.content.interfaces import IContentType >>> class I4(Interface): ... pass >>> IInterface.providedBy(I4) True >>> IContentType.providedBy(I4) False >>> getInterface(None, 'zope.app.component.interface.I4') Traceback (most recent call last): ... ComponentLookupError: 'zope.app.component.interface.I4' >>> provideInterface('', I4, IContentType) >>> IContentType.providedBy(I4) True >>> iface = queryInterface( 'zope.app.component.interface.I4') >>> iface.__name__ 'I4' >>> placelesssetup.tearDown() |
provideInterface(id, interface, iface_type=None, info='')register Interface with global site manager as utility >>> from zope.app.testing import placelesssetup >>> placelesssetup.setUp() >>> gsm = zapi.getGlobalSiteManager() >>> from zope.interface import Interface >>> from zope.interface.interfaces import IInterface >>> from zope.app.content.interfaces import IContentType >>> class I(Interface): ... pass >>> IInterface.providedBy(I) True >>> IContentType.providedBy(I) False >>> interfaces = gsm.getUtilitiesFor(IContentType) >>> list(interfaces) [] # provide first interface type >>> provideInterface('', I, IContentType) >>> IContentType.providedBy(I) True >>> interfaces = list(gsm.getUtilitiesFor(IContentType)) >>> [name for (name, iface) in interfaces] [u'zope.app.component.interface.I'] >>> [iface.__name__ for (name, iface) in interfaces] ['I'] # provide second interface type >>> class IOtherType(IInterface): ... pass >>> provideInterface('', I, IOtherType) >>> IContentType.providedBy(I) True >>> IOtherType.providedBy(I) True >>> interfaces = list(gsm.getUtilitiesFor(IContentType)) >>> [name for (name, iface) in interfaces] [u'zope.app.component.interface.I'] >>> interfaces = list(gsm.getUtilitiesFor(IOtherType)) >>> [name for (name, iface) in interfaces] [u'zope.app.component.interface.I'] >>> class I1(Interface): ... pass >>> provideInterface('', I1) >>> IInterface.providedBy(I1) True >>> IContentType.providedBy(I1) False >>> interfaces = list(gsm.getUtilitiesFor(IContentType)) >>> [name for (name, iface) in interfaces] [u'zope.app.component.interface.I'] >>> [iface.__name__ for (name, iface) in interfaces] ['I'] >>> placelesssetup.tearDown() |
queryInterface(id, default=None)return interface or None >>> from zope.app.testing import placelesssetup >>> placelesssetup.tearDown() >>> placelesssetup.setUp() >>> from zope.interface import Interface >>> from zope.interface.interfaces import IInterface >>> from zope.app.content.interfaces import IContentType >>> class I3(Interface): ... pass >>> IInterface.providedBy(I3) True >>> IContentType.providedBy(I3) False >>> queryInterface('zope.app.component.interface.I3') >>> provideInterface('', I3, IContentType) >>> IContentType.providedBy(I3) True >>> iface = queryInterface('zope.app.component.interface.I3') >>> iface.__name__ 'I3' >>> placelesssetup.tearDown() |
searchInterface(context, search_string=None, base=None)Interfaces search >>> from zope.app.testing import placelesssetup >>> placelesssetup.setUp() >>> from zope.interface import Interface >>> from zope.interface.interfaces import IInterface >>> from zope.app.content.interfaces import IContentType >>> class I5(Interface): ... pass >>> IInterface.providedBy(I5) True >>> IContentType.providedBy(I5) False >>> searchInterface(None, 'zope.app.component.interface.I5') [] >>> provideInterface('', I5, IContentType) >>> IContentType.providedBy(I5) True >>> iface = searchInterface(None, 'zope.app.component.interface.I5') >>> iface[0].__name__ 'I5' >>> placelesssetup.tearDown() |
searchInterfaceIds(context, search_string=None, base=None)Interfaces search >>> from zope.app.testing import placelesssetup >>> placelesssetup.setUp() >>> from zope.interface import Interface >>> from zope.interface.interfaces import IInterface >>> from zope.app.content.interfaces import IContentType >>> class I5(Interface): ... pass >>> IInterface.providedBy(I5) True >>> IContentType.providedBy(I5) False >>> searchInterface(None, 'zope.app.component.interface.I5') [] >>> provideInterface('', I5, IContentType) >>> IContentType.providedBy(I5) True >>> iface = searchInterfaceIds(None, ... 'zope.app.component.interface.I5') >>> iface [u'zope.app.component.interface.I5'] >>> placelesssetup.tearDown() |
Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Fri Jun 24 12:01:21 2005 | http://epydoc.sf.net |