[Zope3-checkins] CVS: Zope3/src/zope/app/browser - marker.pt:1.1 introspector.pt:1.7 introspector.py:1.6 introspector.zcml:1.4
Albertas Agejevas
alga@codeworks.lt
Wed, 2 Jul 2003 11:23:34 -0400
Update of /cvs-repository/Zope3/src/zope/app/browser
In directory cvs.zope.org:/tmp/cvs-serv26198/src/zope/app/browser
Modified Files:
introspector.pt introspector.py introspector.zcml
Added Files:
marker.pt
Log Message:
Directly implemented interface marking through the Introspector.
SteveA has been demonstrating this during his talk at EuroPython. I reckon
he borrowed Guido's time machine...
=== Added File Zope3/src/zope/app/browser/marker.pt ===
<html metal:use-macro="views/standard_macros/page">
<head>
<style type="text/css" 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;
global status view/update">
<form action="" tal:attributes="action request/URL" method="POST">
<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">
<span tal:replace="repeat/base/item" />
<!--
<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">Interfaces from Class:</th>
<td>
<div tal:repeat="interface introspector/getInterfaceNames">
<div tal:define="url python: view.getInterfaceURL(interface)">
<a href=""
tal:attributes="href url"
tal:content="interface"
tal:condition="url">Interface</a>
<span tal:condition="python: not url"
tal:content="interface" />
</div>
</div>
</td>
</tr>
<tr tal:condition="introspector/getDirectlyProvided">
<th class="introspector">Interfaces from Object:</th>
<td>
<div tal:repeat="interface introspector/getDirectlyProvidedNames">
<div tal:define="url python: view.getInterfaceURL(interface)">
<a href=""
tal:attributes="href url"
tal:content="interface"
tal:condition="url">Interface</a>
<span tal:condition="python: not url"
tal:content="interface" />
</div>
</div>
</td>
</tr>
<tr tal:condition="introspector/getDirectlyProvided">
<th class="introspector">Remove Interfaces:</th>
<td>
<div tal:repeat="interface introspector/getDirectlyProvidedNames">
<label><input type="checkbox"
tal:attributes="name string:rem_${interface}"/>
<span tal:replace="interface" />
</label>
</div>
<input type="submit" name="REMOVE" value="Remove" />
</td>
</tr>
<tr tal:condition="introspector/getMarkerInterfaceNames">
<th class="introspector">Add Interfaces:</th>
<td>
<div tal:repeat="interface introspector/getMarkerInterfaceNames">
<label><input type="checkbox"
tal:attributes="name string:add_${interface}"/>
<span tal:replace="interface" />
</label>
</div>
<input type="submit" name="ADD" value="Add" />
</td>
</tr>
</table>
</form>
</tal:block>
</div>
</body>
</html>
=== Zope3/src/zope/app/browser/introspector.pt 1.6 => 1.7 ===
--- Zope3/src/zope/app/browser/introspector.pt:1.6 Wed Jul 2 07:02:15 2003
+++ Zope3/src/zope/app/browser/introspector.pt Wed Jul 2 11:23:01 2003
@@ -137,7 +137,7 @@
</td>
</tr>
<tr>
- <th class="introspector">Interface:</th>
+ <th class="introspector">Interfaces from Class:</th>
<td>
<div tal:repeat="interface introspector/getInterfaceNames">
<div tal:define="url python: view.getInterfaceURL(interface)">
@@ -149,6 +149,27 @@
tal:content="interface" />
</div>
</div>
+ </td>
+ </tr>
+ <tr>
+ <th class="introspector">Interfaces from Object:</th>
+ <td>
+ <div tal:repeat="interface introspector/getDirectlyProvidedNames"
+ tal:condition="introspector/getDirectlyProvided">
+ <div tal:define="url python: view.getInterfaceURL(interface)">
+ <a href=""
+ tal:attributes="href url"
+ tal:content="interface"
+ tal:condition="url">Interface</a>
+ <span tal:condition="python: not url"
+ tal:content="interface" />
+ </div>
+ </div>
+ <form tal:attributes="
+ action string:${request/URL/-1}/@@objectMarker.html"
+ method="POST">
+ <input type="submit" value="Modify" />
+ </form>
</td>
</tr>
</table>
=== Zope3/src/zope/app/browser/introspector.py 1.5 => 1.6 ===
--- Zope3/src/zope/app/browser/introspector.py:1.5 Wed Jul 2 07:02:15 2003
+++ Zope3/src/zope/app/browser/introspector.py Wed Jul 2 11:23:01 2003
@@ -17,6 +17,8 @@
from zope.app import zapi
from zope.app.services.servicenames import Interfaces
from zope.component.exceptions import ComponentLookupError
+from zope.interface import directlyProvides, directlyProvidedBy
+from zope.proxy import removeAllProxies
# XXX only used for commented-out section below
# from zope.component import getServiceManager, getServiceDefinitions, \
# queryAdapter, getService
@@ -37,6 +39,23 @@
return "%s/detail.html?id=%s" % (url, name)
except ComponentLookupError:
return ""
+
+ def update(self):
+ if 'ADD' in self.request:
+ for interface in self.getIntrospector().getMarkerInterfaceNames():
+ if "add_%s" % interface in self.request:
+ interfaces = zapi.getService(self.context, Interfaces)
+ interface = interfaces.getInterface(interface)
+ ob = removeAllProxies(self.context)
+ directlyProvides(ob, directlyProvidedBy(ob), interface)
+
+ if 'REMOVE' in self.request:
+ for interface in self.getIntrospector().getDirectlyProvidedNames():
+ if "rem_%s" % interface in self.request:
+ interfaces = zapi.getService(self.context, Interfaces)
+ interface = interfaces.getInterface(interface)
+ ob = removeAllProxies(self.context)
+ directlyProvides(ob, directlyProvidedBy(ob)-interface)
def getServicesFor(self):
services = []
=== Zope3/src/zope/app/browser/introspector.zcml 1.3 => 1.4 ===
--- Zope3/src/zope/app/browser/introspector.zcml:1.3 Tue Jun 24 14:58:11 2003
+++ Zope3/src/zope/app/browser/introspector.zcml Wed Jul 2 11:23:01 2003
@@ -14,10 +14,15 @@
for = "zope.interface.Interface"
permission="zope.ManageServices"
class="zope.app.browser.introspector.IntrospectorView" >
+
<page name="classBrowser.html"
title="Introspector"
template="introspector.pt"
menu="zmi_views"
+ />
+
+ <page name="objectMarker.html"
+ template="marker.pt"
/>
</pages>