[Zope3-checkins] CVS: Zope3/src/zope/app/browser/services/interface
- method_detail.pt:1.1 __init__.py:1.8 configure.zcml:1.7
detail.pt:1.10
Suresh Babu Eddala
sbabu at zeomega.com
Wed Dec 10 01:55:32 EST 2003
Update of /cvs-repository/Zope3/src/zope/app/browser/services/interface
In directory cvs.zope.org:/tmp/cvs-serv3483/app/browser/services/interface
Modified Files:
__init__.py configure.zcml detail.pt
Added Files:
method_detail.pt
Log Message:
Method detail view added to Interface service
=== Added File Zope3/src/zope/app/browser/services/interface/method_detail.pt ===
<html metal:use-macro="context/@@standard_macros/page">
<body>
<div metal:fill-slot="body" tal:define="ignored view/setup">
<h2 i18n:translate="">
<span tal:replace="string:${view/iface/__name__}.${view/name}${view/method/getSignatureString}">Method Signature</span>
</h2>
<div tal:content="view/doc">This is a doc string.</div>
</div>
</body>
</html>
=== Zope3/src/zope/app/browser/services/interface/__init__.py 1.7 => 1.8 ===
--- Zope3/src/zope/app/browser/services/interface/__init__.py:1.7 Tue Dec 9 08:20:18 2003
+++ Zope3/src/zope/app/browser/services/interface/__init__.py Wed Dec 10 01:55:31 2003
@@ -136,3 +136,61 @@
if regs:
yield {"name": name, "registrations": regs}
+
+class MethodDetail:
+ """Interface Method Details
+
+ >>> from zope.interface import Interface
+ >>> from zope.i18n import MessageIDFactory
+ >>> _ = MessageIDFactory('zope')
+ >>> class TestInterface(Interface):
+ ... '''Test Interface'''
+ ... def testMethod():
+ ... 'Returns test name'
+ ...
+ >>> class TestClass:
+ ... def getInterface(self, id=None):
+ ... return TestInterface
+ ...
+ >>> from zope.publisher.browser import TestRequest
+ >>> request = TestRequest()
+ >>> form = {'interface_id': 'TestInterface', 'method_id': 'testMethod'}
+ >>> request.form = form
+ >>> imethod_details = MethodDetail(TestClass(), request)
+ >>> imethod_details.setup()
+ >>> imethod_details.name
+ 'testMethod'
+ >>> imethod_details.doc
+ 'Returns test name'
+ >>> imethod_details.iface.__name__
+ 'TestInterface'
+ >>> imethod_details.method.__name__
+ 'testMethod'
+
+ """
+
+ def __init__(self, context, request):
+ self.context = context
+ self.request = request
+
+ def setup(self):
+ try:
+ interface_id = self.request["interface_id"]
+ except KeyError:
+ raise zapi.UserError("Please click on a method name in the Detail"
+ " tab to view method details.")
+ try:
+ method_id = self.request["method_id"]
+ except KeyError:
+ raise zapi.UserError("Please click on a method name to view"
+ " details.")
+
+ iface = self.context.getInterface(interface_id)
+
+ from zope.proxy import getProxiedObject
+ self.iface = getProxiedObject(iface)
+
+ self.method = self.iface[method_id]
+ self.name = self.method.__name__
+ self.doc = self.method.__doc__
+
=== Zope3/src/zope/app/browser/services/interface/configure.zcml 1.6 => 1.7 ===
--- Zope3/src/zope/app/browser/services/interface/configure.zcml:1.6 Tue Dec 9 08:09:28 2003
+++ Zope3/src/zope/app/browser/services/interface/configure.zcml Wed Dec 10 01:55:31 2003
@@ -29,4 +29,13 @@
menu="zmi_views" title="Detail"
/>
+ <page
+ for="zope.app.interfaces.component.IInterfaceService"
+ name="method_detail.html"
+ template="method_detail.pt"
+ class=".MethodDetail"
+ permission="zope.ManageServices"
+ menu="zmi_views" title="Method Details"
+ />
+
</zope:configure>
=== Zope3/src/zope/app/browser/services/interface/detail.pt 1.9 => 1.10 ===
--- Zope3/src/zope/app/browser/services/interface/detail.pt:1.9 Tue Dec 9 08:20:18 2003
+++ Zope3/src/zope/app/browser/services/interface/detail.pt Wed Dec 10 01:55:31 2003
@@ -24,11 +24,13 @@
<tr tal:define="oddrow repeat/methoddict/odd;"
tal:attributes="class python:oddrow and 'even' or 'odd'">
<td>
- <strong>
- <span tal:replace="methoddict/method/__name__" /></strong><span
- tal:replace="methoddict/method/getSignatureString">
- Info
- </span>
+ <a href="/"
+ tal:attributes="href string:method_detail.html?interface_id=${request/id}&method_id=${methoddict/method/__name__}">
+ <strong><span tal:replace="string:${methoddict/method/__name__}"
+ >Method Name</span></strong><span
+ tal:replace="string:${methoddict/method/getSignatureString}"
+ >Method Signature</span>
+ </a>
</td>
<td tal:content="methoddict/title"></td>
</tr>
More information about the Zope3-Checkins
mailing list