[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Introspector - IIntrospector.py:1.1.2.1 Introspector.py:1.1.2.1 __init__.py:1.1.2.1 introspector.zcml:1.1.2.1
Gary Poster
garyposter@earthlink.net
Sat, 23 Mar 2002 18:04:34 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Introspector
In directory cvs.zope.org:/tmp/cvs-serv27748/Introspector
Added Files:
Tag: Zope-3x-branch
IIntrospector.py Introspector.py __init__.py introspector.zcml
Log Message:
Added Introspector, changed ofs.zcml to include; introspector links do not work due to no implementation for introspecting interfaces
=== Added File Zope3/lib/python/Zope/App/OFS/Introspector/IIntrospector.py ===
# This software is subject to the provisions of the Zope Public License,
# Version 1.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
from Interface import Interface
class IIntrospector(Interface):
"""An interface for introspecting a component"""
def getName():
"""Returns the component name"""
def getDocString():
"""Returns the description of component (string)"""
def getInterfaces():
"""Returns interfaces implemented by this component (iterator)"""
def getInterfaceNames():
"""Returns dotted names usable by the interface reference"""
=== Added File Zope3/lib/python/Zope/App/OFS/Introspector/Introspector.py ===
# This software is subject to the provisions of the Zope Public License,
# Version 1.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
from Interface import Interface
from Interface.Implements import implements, getImplements
from IIntrospector import IIntrospector
class Introspector:
def __init__(self, component):
self._component=component.__class__
def getName(self):
return self._component.__name__
def getDocString(self):
return self._component.__doc__
def getInterfaces(self):
imple=self._component.__implements__
if type(imple) != tuple:
imple=(imple,)
else:
imple=self._unpackTuple(imple)
return imple
def getInterfaceNames(self):
names=[]
for intObj in self.getInterfaces():
names.append(intObj.__module__ + '.' + intObj.__name__)
names.sort()
return names
def _unpackTuple(self, imple):
res=[]
for imp in imple:
if type(imp)==tuple:
res.extend(self._unpackTuple(imp))
else: res.append(imp)
return tuple(res)
implements(Introspector, IIntrospector)
=== Added File Zope3/lib/python/Zope/App/OFS/Introspector/__init__.py ===
=== Added File Zope3/lib/python/Zope/App/OFS/Introspector/introspector.zcml ===
<zopeConfigure
xmlns='http://namespaces.zope.org/zope'
xmlns:security='http://namespaces.zope.org/security'
xmlns:zmi='http://namespaces.zope.org/zmi'
xmlns:browser='http://namespaces.zope.org/browser'>
<security:permission
permission_id="Zope.App.OFS.Introspector.View"
title="View Component Description" />
<security:protectClass name="Zope.App.OFS.Introspector.Views.Browser.IntrospectorView."
permission_id="Zope.View"
/>
<browser:view
name="api"
factory="Zope.App.OFS.Introspector. Zope.App.OFS.Introspector.Views.Browser.IntrospectorView." />
<security:protectClass name="Zope.App.OFS.Introspector."
permission_id="Zope.View"
interface="Zope.App.OFS.Introspector.IIntrospector."
/>
<adapter
factory="Zope.App.OFS.Introspector."
provides="Zope.App.OFS.Introspector.IIntrospector." />
</zopeConfigure>