[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Introspector - IIntrospector.py:1.2 Introspector.py:1.2 __init__.py:1.2 introspector.zcml:1.2

Jim Fulton jim@zope.com
Mon, 10 Jun 2002 19:28:38 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Introspector
In directory cvs.zope.org:/tmp/cvs-serv17445/lib/python/Zope/App/OFS/Introspector

Added Files:
	IIntrospector.py Introspector.py __init__.py introspector.zcml 
Log Message:
Merged Zope-3x-branch into newly forked Zope3 CVS Tree.


=== Zope3/lib/python/Zope/App/OFS/Introspector/IIntrospector.py 1.1 => 1.2 ===
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+# 
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (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"""
+


=== Zope3/lib/python/Zope/App/OFS/Introspector/Introspector.py 1.1 => 1.2 ===
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+# 
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (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)
\ No newline at end of file


=== Zope3/lib/python/Zope/App/OFS/Introspector/__init__.py 1.1 => 1.2 ===
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+# 
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (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.
+# 
+##############################################################################


=== Zope3/lib/python/Zope/App/OFS/Introspector/introspector.zcml 1.1 => 1.2 ===
+   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
+     id="Zope.App.OFS.Introspector.View" 
+     title="View Component Description" />
+
+  <browser:view
+    name="api"
+     permission="Zope.View"
+    factory="Zope.App.OFS.Introspector.
+             Zope.App.OFS.Introspector.Views.Browser.IntrospectorView." />
+
+  <adapter
+      factory="Zope.App.OFS.Introspector."
+      permission="Zope.View"
+      provides="Zope.App.OFS.Introspector.IIntrospector." />
+
+</zopeConfigure>
+