[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Introspector/Browser - IBrowser.pt:1.2 IntrospectorView.py:1.2 __init__.py:1.2 configure.zcml:1.2

Gary Poster gary@zope.com
Thu, 19 Dec 2002 13:26:05 -0500


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

Added Files:
	IBrowser.pt IntrospectorView.py __init__.py configure.zcml 
Log Message:
Cleaned up merge of Introspector work in Bangalore branch.  will not be hooked up until the OFS configure.zcml is also committed: I'm going to test my commit before I do so.

When this is hooked up, it will add an Introspector action in the UI.

This html was broken in the Rotterdam skin; fixed and significantly cleaned up.

A lot of DOS line endings were removed.  dos2unix reports that all is well now.

Commented-out code in the view refers to an IConfigureFor interface that goes in a direction that Jim eventually wants.  I am not merging in the necessary code elsewhere (in the services) that this code needs, so therefore I comment it out but do not delete it.

Introspector tab will be available to anonymous user, as it was in the branch.  If we don't like this, we can just fix the zcml.




=== Zope3/lib/python/Zope/App/OFS/Introspector/Browser/IBrowser.pt 1.1 => 1.2 ===
--- /dev/null	Thu Dec 19 13:26:05 2002
+++ Zope3/lib/python/Zope/App/OFS/Introspector/Browser/IBrowser.pt	Thu Dec 19 13:25:33 2002
@@ -0,0 +1,155 @@
+<html metal:use-macro="views/standard_macros/page">
+<head>
+
+<style metal:fill-slot="style_slot">
+.preclass {
+    color : #000066;
+    font-family : monospace;
+    white-space : pre;
+    }
+th.introspector {
+    vertical-align: top;
+    }
+</style>
+</head>
+
+<body>
+<div metal:fill-slot="body">
+<tal:block 
+    tal:define = 
+       "global introspector view/getIntrospector;
+        global services view/getServicesFor">
+
+<div tal:condition="python:introspector.isInterface()">
+
+<table tal:define = 
+    "global interfacedata introspector/getInterfaceDetails">
+    <tr>
+        <th colspan="2">Interface Browser</th>
+    </tr>
+    <tr>
+        <th class="introspector">Interface :</th>
+        <td tal:content="python:interfacedata[0]">Interface</td>
+    </tr>
+    <tr>
+        <th class="introspector">Bases :</th>
+        <td>
+            <div tal:repeat="interface python:interfacedata[1]">
+                <a href="" 
+                    tal:attributes="href 
+                        string: ++module++${repeat/interface/item}"  
+                    tal:content="repeat/interface/item">Interface</a>
+            </div>
+        </td>
+    </tr>
+    <tr>
+        <th class="introspector">Description :</th>
+        <td>
+        <!-- the start of all of these preclass spans are carefully 
+        spatially placed (in terms of whitespace), because they are 
+        "pre" formatted (i.e., whitespace matters within the span) -->
+        <span class="preclass"
+                tal:content="python:interfacedata[2]">
+                Description</span>
+        </td>
+    </tr>
+    <tr>
+        <th class="introspector">Attributes :</th>
+        <td>
+            <div tal:repeat="attributes python:interfacedata[4]">
+                <tal:block tal:define="details repeat/attributes/item">
+                    <strong tal:content="python:details[0]">
+                        Atttribute Name</strong>
+                    <div class="preclass">
+        <span
+                        tal:content="python:details[1]">
+                        Attribute Description</span></div>
+                </tal:block>
+            </div>
+        </td>
+    </tr>
+    <tr>
+        <th class="introspector">Methods :</th>
+        <td>
+            <div tal:repeat="methods python:interfacedata[3]">
+                <tal:block tal:define="details repeat/methods/item">
+                    <strong tal:content="python:details[0]">
+                        Method Name</strong>
+                    <strong tal:content="python:details[1]">
+                        Signature</strong>
+                    <div class="preclass">
+        <span 
+                        tal:content="python:details[2]">
+                        Method Description</span></div>
+		</tal:block>
+	    </div>
+        </td>
+    </tr>
+    <!-- this section is currently not available
+    <tr>
+        <th class="introspector">Services :</th>
+        <td>
+	    <div tal:repeat="servicedic services">
+                <span tal:define="dic repeat/servicedic/item">
+                    <a tal:content="python:dic.keys()[0]"/>
+                </span>
+	    </div>
+        </td>
+    </tr> 
+    -->
+</table>
+</div>
+
+<div tal:condition="python:introspector.isInterface()==0">
+
+<table>
+    <tr>
+        <th colspan="2">Class Browser</th>
+    </tr>
+    <tr>
+        <th class="introspector">Class :</th>
+        <td><span tal:content="introspector/getClass">Name</span></td>
+    </tr>
+    <tr>
+        <th class="introspector">Bases :</th>
+        <td>
+            <div tal:repeat="base introspector/getBaseClassNames">
+                <a href="" 
+                    tal:attributes="href 
+                        string: ++module++${repeat/base/item}"  
+                    tal:content="repeat/base/item">Base</a>
+            </div>
+        </td>
+    </tr>
+    <tr>
+        <th class="introspector">Module :</th>
+        <td><span tal:content="introspector/getModule">Module</span></td>
+    </tr>
+    <tr>
+        <th>Description :</th>
+        <td>
+        <span class="preclass" 
+                tal:content="introspector/getDocString">
+                Description</span>
+        </td>
+    </tr>
+    <tr>
+        <th class="introspector">Interface :</th>
+        <td>
+            <div tal:repeat="interface introspector/getInterfaceNames">
+                <a href="" 
+                    tal:attributes="href 
+                        string: ++module++${repeat/interface/item}"
+                    tal:content="repeat/interface/item">Interface</a>
+            </div>
+        </td>
+    </tr>
+</table>
+</div>
+
+</tal:block>
+
+</div>
+</body>
+</html>
+


=== Zope3/lib/python/Zope/App/OFS/Introspector/Browser/IntrospectorView.py 1.1 => 1.2 ===
--- /dev/null	Thu Dec 19 13:26:05 2002
+++ Zope3/lib/python/Zope/App/OFS/Introspector/Browser/IntrospectorView.py	Thu Dec 19 13:25:33 2002
@@ -0,0 +1,64 @@
+##############################################################################
+#
+# 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 Zope.ComponentArchitecture import getAdapter
+from Zope.Publisher.Browser.BrowserView import BrowserView
+from Zope.App.OFS.Introspector.IIntrospector import IIntrospector
+from Zope.App.PageTemplate import ViewPageTemplateFile
+from Zope.ComponentArchitecture import getServiceManager, getAdapter, \
+     queryServiceManager, getServiceDefinitions, queryAdapter, getService
+# from Zope.App.OFS.Services.IConfigureFor import IConfigureFor
+from Zope.ComponentArchitecture.Exceptions import ComponentLookupError
+
+class IntrospectorView(BrowserView):
+    
+    def getIntrospector(self):
+        introspector = getAdapter(self.context, IIntrospector)
+        introspector.setRequest(self.request)
+        return introspector
+
+    def getServicesFor(self):
+        services = []
+        #sm = getServiceManager(self.context)
+        #for stype, interface in sm.getServiceDefinitions():
+        #    try:
+        #        service = getService(self.context, stype)
+        #    except ComponentLookupError:
+        #        pass
+        #    else:
+        #        adapter = queryAdapter(service, IConfigureFor)
+        #        if adapter is not None and adapter.hasConfigurationFor(self.context):
+        #            search_result = service.getRegisteredMatching(self.context, None, [], self.context)
+        #            directive_path = []
+        #            if search_result:
+        #                for eachitem in search_result:
+        #                    dir_list = eachitem['directives']
+        #                    component_path = eachitem['component_path']
+        #                    for item in dir_list:
+        #                        directives = item[2]                         
+        #                        if directives:
+        #                            if directives[0] is None:
+        #                                directives = directives[1:]
+        #                            for directive in directives:
+        #                                for component in component_path:
+        #                                    if component['component'] == directive:
+        #                                        directive_path.append(component['path'])
+        #            services.append({
+        #                'type': stype,
+        #                'service': service,
+        #                'path': directive_path
+        #                })
+        return services
+                    
+                
+                
\ No newline at end of file


=== Zope3/lib/python/Zope/App/OFS/Introspector/Browser/__init__.py 1.1 => 1.2 ===
--- /dev/null	Thu Dec 19 13:26:05 2002
+++ Zope3/lib/python/Zope/App/OFS/Introspector/Browser/__init__.py	Thu Dec 19 13:25:33 2002
@@ -0,0 +1,13 @@
+##############################################################################
+#
+# 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/Browser/configure.zcml 1.1 => 1.2 ===
--- /dev/null	Thu Dec 19 13:26:05 2002
+++ Zope3/lib/python/Zope/App/OFS/Introspector/Browser/configure.zcml	Thu Dec 19 13:25:33 2002
@@ -0,0 +1,29 @@
+<zopeConfigure 
+    xmlns='http://namespaces.zope.org/zope'
+    xmlns:browser='http://namespaces.zope.org/browser'>
+
+<browser:defaultView
+    name="classBrowser.html"
+    for = "Interface.Interface"
+    permission="Zope.View"
+    template="IBrowser.pt"
+    factory=".IntrospectorView."
+    />
+
+<browser:menuItem 
+    for = "Interface.Interface" 
+    title="Introspector" 
+    menu="zmi_views" 
+    action="classBrowser.html"/>
+ 
+
+<browser:defaultView
+    name="interfaceBrowser.html"
+    for="Interface.IInterface."
+    permission="Zope.View"
+    template="IBrowser.pt"
+    factory=".IntrospectorView."
+    /> 
+
+ 
+</zopeConfigure>