[Zope3-checkins]
SVN: Zope3/trunk/src/zope/app/apidoc/codemodule/browser/introspector.
The introspector now removes all the proxies from the object
before getting
Dmitry Vasiliev
dima at hlabs.spb.ru
Sat Mar 19 14:12:12 EST 2005
Log message for revision 29576:
The introspector now removes all the proxies from the object before getting
any information
Changed:
U Zope3/trunk/src/zope/app/apidoc/codemodule/browser/introspector.py
U Zope3/trunk/src/zope/app/apidoc/codemodule/browser/introspector.txt
-=-
Modified: Zope3/trunk/src/zope/app/apidoc/codemodule/browser/introspector.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/codemodule/browser/introspector.py 2005-03-19 18:05:32 UTC (rev 29575)
+++ Zope3/trunk/src/zope/app/apidoc/codemodule/browser/introspector.py 2005-03-19 19:12:12 UTC (rev 29576)
@@ -20,24 +20,27 @@
import zope.interface
from zope.security.proxy import removeSecurityProxy
+from zope.app.container.contained import getProxiedObject
from zope.app.publisher.browser import BrowserView
class Introspector(BrowserView):
+ def get_object(self):
+ return getProxiedObject(removeSecurityProxy(self.context))
+
def class_name(self):
- klass = type(removeSecurityProxy(self.context))
+ klass = type(self.get_object())
return "%s.%s" % (klass.__module__, klass.__name__)
def class_url(self):
- klass = type(removeSecurityProxy(self.context))
+ klass = type(self.get_object())
url = self.request.getApplicationURL() + '/++apidoc++/Code/'
url += klass.__module__.replace('.', '/') + '/'
return url + klass.__name__ + '/index.html'
def direct_interfaces(self):
- ob = removeSecurityProxy(self.context)
- ifaces = zope.interface.directlyProvidedBy(ob)
+ ifaces = zope.interface.directlyProvidedBy(self.get_object())
result = []
urlbase = self.request.getApplicationURL() + '/++apidoc++/Interface/'
for iface in ifaces:
Modified: Zope3/trunk/src/zope/app/apidoc/codemodule/browser/introspector.txt
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/codemodule/browser/introspector.txt 2005-03-19 18:05:32 UTC (rev 29575)
+++ Zope3/trunk/src/zope/app/apidoc/codemodule/browser/introspector.txt 2005-03-19 19:12:12 UTC (rev 29576)
@@ -23,10 +23,10 @@
>>> ("http://localhost/++apidoc++/Code/"
... "zope/app/folder/folder/Folder/index.html") in response
True
- >>> "zope.app.folder.folder.Folder" in response
+ >>> ">zope.app.folder.folder.Folder</" in response
True
-Information about the directly provided information is provided by
+Information about the directly provided interfaces is provided by
links from the provided interface names to the introspection pages for
the interfaces::
@@ -41,3 +41,47 @@
True
>>> ">zope.app.folder.interfaces.IRootFolder</" in response
True
+
+All the proxies will be removed from the object before getting
+any information. For example let's add a file::
+
+ >>> print http(r"""
+ ... POST /+/zope.app.file.File%3D HTTP/1.1
+ ... Authorization: Basic mgr:mgrpw
+ ... Content-Type: multipart/form-data; boundary=---------------------------24464570528145
+ ... -----------------------------24464570528145
+ ... Content-Disposition: form-data; name="field.contentType"
+ ...
+ ... -----------------------------24464570528145
+ ... Content-Disposition: form-data; name="field.data"; filename=""
+ ... Content-Type: application/octet-stream
+ ...
+ ... -----------------------------24464570528145
+ ... Content-Disposition: form-data; name="UPDATE_SUBMIT"
+ ...
+ ... Add
+ ... -----------------------------24464570528145
+ ... Content-Disposition: form-data; name="add_input_name"
+ ...
+ ... file
+ ... -----------------------------24464570528145--
+ ... """)
+ HTTP/1.1 303 See Other
+ ...
+
+And now we can check the class that the file implements::
+
+ >>> response = str(http(r"""
+ ... GET /file/@@introspector.html HTTP/1.1
+ ... Authorization: Basic mgr:mgrpw
+ ... """))
+
+ >>> print response
+ HTTP/1.1 200 Ok
+ ...
+
+ >>> ("http://localhost/++apidoc++/Code/"
+ ... "zope/app/file/file/File/index.html") in response
+ True
+ >>> ">zope.app.file.file.File</" in response
+ True
More information about the Zope3-Checkins
mailing list