[Checkins] SVN: Sandbox/ulif/grok-adminui/src/grok/admin/ Added
support for browsing attributes.
Uli Fouquet
uli at gnufix.de
Mon Jul 16 11:59:00 EDT 2007
Log message for revision 78033:
Added support for browsing attributes.
Changed:
U Sandbox/ulif/grok-adminui/src/grok/admin/docgrok.py
U Sandbox/ulif/grok-adminui/src/grok/admin/docgrok.txt
U Sandbox/ulif/grok-adminui/src/grok/admin/view.py
U Sandbox/ulif/grok-adminui/src/grok/admin/view_templates/docgrokclassview.pt
U Sandbox/ulif/grok-adminui/src/grok/admin/view_templates/docgrokgrokapplicationview.pt
U Sandbox/ulif/grok-adminui/src/grok/admin/view_templates/docgrokinterfaceview.pt
-=-
Modified: Sandbox/ulif/grok-adminui/src/grok/admin/docgrok.py
===================================================================
--- Sandbox/ulif/grok-adminui/src/grok/admin/docgrok.py 2007-07-16 14:26:49 UTC (rev 78032)
+++ Sandbox/ulif/grok-adminui/src/grok/admin/docgrok.py 2007-07-16 15:58:59 UTC (rev 78033)
@@ -32,7 +32,10 @@
from zope.app.apidoc.codemodule.text import TextFile
from zope.app.apidoc.utilities import renderText
from zope.app.apidoc.utilities import getFunctionSignature
+from zope.app.apidoc.utilities import getPythonPath, getPermissionIds
+from zope.app.apidoc.utilities import isReferencable
+
grok.context(IRootFolder)
grok.define_permission('grok.ManageApplications')
@@ -198,8 +201,6 @@
return DocGrok(dotted_path)
def getInterfaceInfo(iface):
- from zope.app.apidoc.utilities import getPythonPath
- from zope.app.apidoc.utilities import isReferencable
if iface is None:
return None
path = getPythonPath(iface)
@@ -526,9 +527,23 @@
filename = filename[:-1]
return filename
+ def getAttributes(self):
+ """Get the attributes of this class."""
+ attrs = []
+ # See remark in getMethods()
+ klass = removeSecurityProxy(self.apidoc)
+ for name, attr, iface in klass.getAttributes():
+ entry = {'name': name,
+ 'value': `attr`,
+ 'type': type(attr).__name__,
+ 'interface': iface
+ }
+ entry.update(getPermissionIds(name,klass.getSecurityChecker()))
+ attrs.append(entry)
+ return attrs
+
def getMethods(self):
"""Get all methods of this class."""
- from zope.app.apidoc.utilities import getPythonPath, getPermissionIds
methods = []
# remove the security proxy, so that `attr` is not proxied. We could
# unproxy `attr` for each turn, but that would be less efficient.
@@ -536,7 +551,6 @@
# `getPermissionIds()` also expects the class's security checker not
# to be proxied.
klass = removeSecurityProxy(self.apidoc)
- #klass = resolve(context.path)
for name, attr, iface in klass.getMethodDescriptors():
entry = {'name': name,
'signature': "(...)",
@@ -555,27 +569,8 @@
entry.update(getPermissionIds(name, klass.getSecurityChecker()))
methods.append(entry)
return methods
-
- for name, attr, iface in klass.getMethodDescriptors():
- entry = {'name': name,
- 'signature': "(...)",
- 'doc': renderText(attr.__doc__ or '',
- inspect.getmodule(attr)),
- 'interface': getInterfaceInfo(iface)}
- entry.update(getPermissionIds(name, klass.getSecurityChecker()))
- methods.append(entry)
- for name, attr, iface in klass.getMethods():
- entry = {'name': name,
- 'signature': getFunctionSignature(attr),
- 'doc': renderText(attr.__doc__ or '',
- inspect.getmodule(attr)),
- 'interface': getInterfaceInfo(iface)}
- entry.update(getPermissionIds(name, klass.getSecurityChecker()))
- methods.append(entry)
- return methods
-
class DocGrokInterface(DocGrokClass):
"""This doctor cares for interfaces.
"""
Modified: Sandbox/ulif/grok-adminui/src/grok/admin/docgrok.txt
===================================================================
--- Sandbox/ulif/grok-adminui/src/grok/admin/docgrok.txt 2007-07-16 14:26:49 UTC (rev 78032)
+++ Sandbox/ulif/grok-adminui/src/grok/admin/docgrok.txt 2007-07-16 15:58:59 UTC (rev 78033)
@@ -44,13 +44,9 @@
http://localhost:8080/docgrok/grok/admin
In this way nearly all things can be described, which can be described
-by a dotted name notation and which are accessible at runtime. Also
-normal Python elements can be examined, say, the ``os.path`` package
+by a dotted name notation and which are accessible at runtime.
- http://localhost:8080/docgrok/os/path
-and many more.
-
Calling the doctor directly
+++++++++++++++++++++++++++
Modified: Sandbox/ulif/grok-adminui/src/grok/admin/view.py
===================================================================
--- Sandbox/ulif/grok-adminui/src/grok/admin/view.py 2007-07-16 14:26:49 UTC (rev 78032)
+++ Sandbox/ulif/grok-adminui/src/grok/admin/view.py 2007-07-16 15:58:59 UTC (rev 78033)
@@ -1,5 +1,7 @@
import grok
import os
+import inspect
+from grok.admin import docgrok
from grok.admin.docgrok import DocGrok, DocGrokPackage, DocGrokModule
from grok.admin.docgrok import DocGrokClass, DocGrokInterface, DocGrokGrokApplication
from grok.admin.docgrok import DocGrokTextFile
@@ -34,6 +36,8 @@
class Add(grok.View):
+ """Add an application.
+ """
grok.require('grok.ManageApplications')
@@ -54,6 +58,8 @@
class Delete(grok.View):
+ """Delete an application.
+ """
grok.require('grok.ManageApplications')
@@ -203,7 +209,6 @@
grok.require('grok.ManageApplications')
def getDocOfApp(self, apppath, headonly = True):
- from grok.admin import docgrok
doctor = docgrok.handle(apppath)
result = doctor.getDoc(headonly)
if result is None:
@@ -305,7 +310,12 @@
class DocGrokView(GAIAView):
+ """A base DocGrok view.
+ This view is used for all things not covered by other, more
+ specialized views.
+ """
+
grok.context(DocGrok)
grok.name( 'index' )
@@ -415,18 +425,21 @@
class DocGrokPackageView(DocGrokView):
+ """A view for packages handled by DocGrok."""
grok.context(DocGrokPackage)
grok.name( 'index' )
class DocGrokModuleView(DocGrokView):
+ """A view for modules handled by DocGrok."""
grok.context(DocGrokModule)
grok.name( 'index' )
class DocGrokClassView(DocGrokView):
+ """A view for classes handled by DocGrok."""
grok.context(DocGrokClass)
grok.name( 'index' )
@@ -438,21 +451,20 @@
return self._listClasses(
[iface for iface in self.context.apidoc.getInterfaces()])
+ def getAttributes(self):
+ attrs = self.context.getAttributes()
+ for a in attrs:
+ a['interface'] = self._listClasses([a['interface']])
+ return attrs
+
def getMethods(self):
- import inspect
methods = self.context.getMethods()
for m in methods:
- m['doc'] = self.getDoc(m['doc'])
m['doc'] = renderText(m['attr'].__doc__ or '',
inspect.getmodule(m['attr']))
m['interface'] = self._listClasses([m['interface']])
- pass
return methods
- return self.context.getMethods()
- def getMethodDescriptors(self):
- return self.context.apidoc.getMethodDescriptors()
-
def _listClasses(self, classes):
info = []
for cls in classes:
Modified: Sandbox/ulif/grok-adminui/src/grok/admin/view_templates/docgrokclassview.pt
===================================================================
--- Sandbox/ulif/grok-adminui/src/grok/admin/view_templates/docgrokclassview.pt 2007-07-16 14:26:49 UTC (rev 78032)
+++ Sandbox/ulif/grok-adminui/src/grok/admin/view_templates/docgrokclassview.pt 2007-07-16 15:58:59 UTC (rev 78033)
@@ -118,6 +118,74 @@
</div>
</div>
+
+ <h2>Attributes:</h2>
+ <div class="docgrok-entry" tal:repeat="item view/getAttributes">
+ <div class="docgrok-description2">
+ <span class="docgrok-description1">
+ <span class="docgrok-pathvalue">
+ <span tal:content="item/name">attributename</span>
+ </span>
+ </span>
+ (type: <span class="docgrok-description2" tal:content="item/type">type</span>)
+ </div>
+
+ <div class="docgrok-annotation2">
+ <span class="docgrok-description2">value:</span>
+ <span class="docgrok-pathvalue" tal:content="item/value">value</span>
+ </div>
+
+ <div class="docgrok-annotation2">
+ <div class="docgrok-entry" tal:repeat="iface item/interface">
+ <span class="docgrok-description2">interface:</span>
+ <span class="docgrok-pathvalue">
+ <a href=""
+ tal:attributes="href string:${view/root_url}/docgrok/${iface/url}"
+ tal:content="iface/name">
+ ClassName
+ </a>
+ </span>
+ in
+ <span class="docgrok-pathvalue">
+ <a href=""
+ tal:repeat="part iface/path_parts"
+ tal:attributes="href string:${view/root_url}${part/url}">
+
+ <span tal:replace="part/name" />
+ </a>
+ </span>
+ <div class="docgrok-annotation2"
+ tal:condition="iface/doc"
+ tal:content="structure iface/doc">
+ </div>
+ <div class="docgrok-annotation2"
+ tal:condition="not: iface/doc">
+ Use <span class="docgrok-pycode1">from <span
+ tal:replace="iface/path">x</span> import <span
+ tal:replace="iface/name">y</span></span> to make the
+ functionality of this class available in your application
+ or component.
+ </div>
+ </div>
+
+ </div>
+
+ <div class="docgrok-annotation2">
+ <span class="docgrok-description2">permissions:</span>
+ <div class="docgrok-annotation2">
+ read:
+ <span tal:content="item/read_perm">None</span>
+ </div>
+ <div class="docgrok-annotation2">
+ write:
+ <span tal:content="item/write_perm">None</span>
+ </div>
+ </div>
+
+
+ </div>
+
+
<h2>Functions:</h2>
<div class="docgrok-entry" tal:repeat="item view/getEntries">
Modified: Sandbox/ulif/grok-adminui/src/grok/admin/view_templates/docgrokgrokapplicationview.pt
===================================================================
--- Sandbox/ulif/grok-adminui/src/grok/admin/view_templates/docgrokgrokapplicationview.pt 2007-07-16 14:26:49 UTC (rev 78032)
+++ Sandbox/ulif/grok-adminui/src/grok/admin/view_templates/docgrokgrokapplicationview.pt 2007-07-16 15:58:59 UTC (rev 78033)
@@ -114,10 +114,77 @@
</div>
</div>
- <div tal:repeat="iface view/getInterfaces">
- <div tal:content="python: str(iface)">asd</div>
+
+
+
+ <h2>Attributes:</h2>
+ <div class="docgrok-entry" tal:repeat="item view/getAttributes">
+ <div class="docgrok-description2">
+ <span class="docgrok-description1">
+ <span class="docgrok-pathvalue">
+ <span tal:content="item/name">attributename</span>
+ </span>
+ </span>
+ (type: <span class="docgrok-description2" tal:content="item/type">type</span>)
+ </div>
+
+ <div class="docgrok-annotation2">
+ <span class="docgrok-description2">value:</span>
+ <span class="docgrok-pathvalue" tal:content="item/value">value</span>
+ </div>
+
+ <div class="docgrok-annotation2">
+ <div class="docgrok-entry" tal:repeat="iface item/interface">
+ <span class="docgrok-description2">interface:</span>
+ <span class="docgrok-pathvalue">
+ <a href=""
+ tal:attributes="href string:${view/root_url}/docgrok/${iface/url}"
+ tal:content="iface/name">
+ ClassName
+ </a>
+ </span>
+ in
+ <span class="docgrok-pathvalue">
+ <a href=""
+ tal:repeat="part iface/path_parts"
+ tal:attributes="href string:${view/root_url}${part/url}">
+
+ <span tal:replace="part/name" />
+ </a>
+ </span>
+ <div class="docgrok-annotation2"
+ tal:condition="iface/doc"
+ tal:content="structure iface/doc">
+ </div>
+ <div class="docgrok-annotation2"
+ tal:condition="not: iface/doc">
+ Use <span class="docgrok-pycode1">from <span
+ tal:replace="iface/path">x</span> import <span
+ tal:replace="iface/name">y</span></span> to make the
+ functionality of this class available in your application
+ or component.
+ </div>
+ </div>
+
+ </div>
+
+ <div class="docgrok-annotation2">
+ <span class="docgrok-description2">permissions:</span>
+ <div class="docgrok-annotation2">
+ read:
+ <span tal:content="item/read_perm">None</span>
+ </div>
+ <div class="docgrok-annotation2">
+ write:
+ <span tal:content="item/write_perm">None</span>
+ </div>
+ </div>
+
+
</div>
-<!--
+
+
+
<h2>Functions:</h2>
<div class="docgrok-entry" tal:repeat="item view/getEntries">
@@ -139,68 +206,77 @@
Use <span class="docgrok-pycode1">from <span
tal:replace="context/path">x</span> import <span
tal:replace="item/name">y</span></span> to make the
- functionality of this class available in your application
+ functionality of this function available in your application
or component.
</div>
</div>
</div>
- <h2>Interfaces:</h2>
-
- <div class="docgrok-entry" tal:repeat="item view/getEntries">
- <div tal:condition="item/isinterface">
+ <h2>Methods:</h2>
+ <div class="docgrok-entry" tal:repeat="item view/getMethods">
+ <div class="docgrok-description1">
<div class="docgrok-pathvalue">
- interface
- <a href=""
- tal:attributes="href string:${view/root_url}/docgrok/${item/url}"
- tal:content="item/name">
- InterfaceName
- </a>
+ <span tal:content="item/name">methodname</span><span tal:content="item/signature">(signature)</span>
</div>
- <div class="docgrok-annotation2"
- tal:condition="item/doc"
- tal:content="structure item/doc">
+ </div>
+ <div class="docgrok-annotation2"
+ tal:condition="item/doc"
+ tal:content="structure item/doc">
+ Doc
+ </div>
+ <div class="docgrok-annotation2">
+ <div class="docgrok-entry" tal:repeat="iface item/interface">
+ <span class="docgrok-description2">interface:</span>
+ <span class="docgrok-pathvalue">
+ <a href=""
+ tal:attributes="href string:${view/root_url}/docgrok/${iface/url}"
+ tal:content="iface/name">
+ ClassName
+ </a>
+ </span>
+ in
+ <span class="docgrok-pathvalue">
+ <a href=""
+ tal:repeat="part iface/path_parts"
+ tal:attributes="href string:${view/root_url}${part/url}">
+
+ <span tal:replace="part/name" />
+ </a>
+ </span>
+ <div class="docgrok-annotation2"
+ tal:condition="iface/doc"
+ tal:content="structure iface/doc">
+ </div>
+ <div class="docgrok-annotation2"
+ tal:condition="not: iface/doc">
+ Use <span class="docgrok-pycode1">from <span
+ tal:replace="iface/path">x</span> import <span
+ tal:replace="iface/name">y</span></span> to make the
+ functionality of this class available in your application
+ or component.
+ </div>
</div>
- <div class="docgrok-annotation2"
- tal:condition="not: item/doc">
- Use <span class="docgrok-pycode1">from <span
- tal:replace="context/path">x</span> import <span
- tal:replace="item/name">y</span></span> to make this
- interface definition available in your application
- or component.
- </div>
+
</div>
- </div>
- <h2>Classes:</h2>
- <div class="docgrok-entry" tal:repeat="item view/getEntries">
- <div tal:condition="item/isclass">
- <div class="docgrok-pathvalue">
- class
- <a href=""
- tal:attributes="href string:${view/root_url}/docgrok/${item/url}"
- tal:content="item/name">
- ClassName
- </a>
+ <div class="docgrok-annotation2">
+ <span class="docgrok-description2">permissions:</span>
+ <div class="docgrok-annotation2">
+ read:
+ <span tal:content="item/read_perm">None</span>
</div>
- <div class="docgrok-annotation2"
- tal:condition="item/doc"
- tal:content="structure item/doc">
+ <div class="docgrok-annotation2">
+ write:
+ <span tal:content="item/write_perm">None</span>
</div>
- <div class="docgrok-annotation2"
- tal:condition="not: item/doc">
- Use <span class="docgrok-pycode1">from <span
- tal:replace="context/path">x</span> import <span
- tal:replace="item/name">y</span></span> to make the
- functionality of this class available in your application
- or component.
- </div>
</div>
+
+
</div>
--->
</div>
+
</div>
</body>
</html>
Modified: Sandbox/ulif/grok-adminui/src/grok/admin/view_templates/docgrokinterfaceview.pt
===================================================================
--- Sandbox/ulif/grok-adminui/src/grok/admin/view_templates/docgrokinterfaceview.pt 2007-07-16 14:26:49 UTC (rev 78032)
+++ Sandbox/ulif/grok-adminui/src/grok/admin/view_templates/docgrokinterfaceview.pt 2007-07-16 15:58:59 UTC (rev 78033)
@@ -46,7 +46,7 @@
</div>
<div>
- <h2>Base Classes</h2>
+ <h2>Base Interfaces</h2>
<div class="docgrok-entry" tal:repeat="item view/getBases">
class
@@ -80,44 +80,75 @@
</div>
</div>
- <h2>Interfaces</h2>
- <div class="docgrok-entry" tal:repeat="item view/getInterfaces">
- interface
- <span class="docgrok-pathvalue">
- <a href=""
- tal:attributes="href string:${view/root_url}/docgrok/${item/url}"
- tal:content="item/name">
- ClassName
- </a>
- </span>
- in
- <span class="docgrok-pathvalue">
- <a href=""
- tal:repeat="part item/path_parts"
- tal:attributes="href string:${view/root_url}${part/url}">
+ <h2>Attributes:</h2>
+ <div class="docgrok-entry" tal:repeat="item view/getAttributes">
+ <div class="docgrok-description2">
+ <span class="docgrok-description1">
+ <span class="docgrok-pathvalue">
+ <span tal:content="item/name">attributename</span>
+ </span>
+ </span>
+ (type: <span class="docgrok-description2" tal:content="item/type">type</span>)
+ </div>
- <span tal:replace="part/name" />
- </a>
- </span>
- <div class="docgrok-annotation2"
- tal:condition="item/doc"
- tal:content="structure item/doc">
+ <div class="docgrok-annotation2">
+ <span class="docgrok-description2">value:</span>
+ <span class="docgrok-pathvalue" tal:content="item/value">value</span>
</div>
- <div class="docgrok-annotation2"
- tal:condition="not: item/doc">
- Use <span class="docgrok-pycode1">from <span
- tal:replace="item/path">x</span> import <span
- tal:replace="item/name">y</span></span> to make the
- functionality of this class available in your application
- or component.
+
+ <div class="docgrok-annotation2">
+ <div class="docgrok-entry" tal:repeat="iface item/interface">
+ <span class="docgrok-description2">interface:</span>
+ <span class="docgrok-pathvalue">
+ <a href=""
+ tal:attributes="href string:${view/root_url}/docgrok/${iface/url}"
+ tal:content="iface/name">
+ ClassName
+ </a>
+ </span>
+ in
+ <span class="docgrok-pathvalue">
+ <a href=""
+ tal:repeat="part iface/path_parts"
+ tal:attributes="href string:${view/root_url}${part/url}">
+
+ <span tal:replace="part/name" />
+ </a>
+ </span>
+ <div class="docgrok-annotation2"
+ tal:condition="iface/doc"
+ tal:content="structure iface/doc">
+ </div>
+ <div class="docgrok-annotation2"
+ tal:condition="not: iface/doc">
+ Use <span class="docgrok-pycode1">from <span
+ tal:replace="iface/path">x</span> import <span
+ tal:replace="iface/name">y</span></span> to make the
+ functionality of this class available in your application
+ or component.
+ </div>
+ </div>
+
</div>
+
+ <div class="docgrok-annotation2">
+ <span class="docgrok-description2">permissions:</span>
+ <div class="docgrok-annotation2">
+ read:
+ <span tal:content="item/read_perm">None</span>
+ </div>
+ <div class="docgrok-annotation2">
+ write:
+ <span tal:content="item/write_perm">None</span>
+ </div>
+ </div>
+
+
</div>
- <div tal:repeat="iface view/getInterfaces">
- <div tal:content="python: str(iface)">asd</div>
- </div>
-<!--
+
+
<h2>Functions:</h2>
<div class="docgrok-entry" tal:repeat="item view/getEntries">
@@ -139,66 +170,75 @@
Use <span class="docgrok-pycode1">from <span
tal:replace="context/path">x</span> import <span
tal:replace="item/name">y</span></span> to make the
- functionality of this class available in your application
+ functionality of this function available in your application
or component.
</div>
</div>
</div>
- <h2>Interfaces:</h2>
-
- <div class="docgrok-entry" tal:repeat="item view/getEntries">
- <div tal:condition="item/isinterface">
+ <h2>Methods:</h2>
+ <div class="docgrok-entry" tal:repeat="item view/getMethods">
+ <div class="docgrok-description1">
<div class="docgrok-pathvalue">
- interface
- <a href=""
- tal:attributes="href string:${view/root_url}/docgrok/${item/url}"
- tal:content="item/name">
- InterfaceName
- </a>
+ <span tal:content="item/name">methodname</span><span tal:content="item/signature">(signature)</span>
</div>
- <div class="docgrok-annotation2"
- tal:condition="item/doc"
- tal:content="structure item/doc">
+ </div>
+ <div class="docgrok-annotation2"
+ tal:condition="item/doc"
+ tal:content="structure item/doc">
+ Doc
+ </div>
+ <div class="docgrok-annotation2">
+ <div class="docgrok-entry" tal:repeat="iface item/interface">
+ <span class="docgrok-description2">interface:</span>
+ <span class="docgrok-pathvalue">
+ <a href=""
+ tal:attributes="href string:${view/root_url}/docgrok/${iface/url}"
+ tal:content="iface/name">
+ ClassName
+ </a>
+ </span>
+ in
+ <span class="docgrok-pathvalue">
+ <a href=""
+ tal:repeat="part iface/path_parts"
+ tal:attributes="href string:${view/root_url}${part/url}">
+
+ <span tal:replace="part/name" />
+ </a>
+ </span>
+ <div class="docgrok-annotation2"
+ tal:condition="iface/doc"
+ tal:content="structure iface/doc">
+ </div>
+ <div class="docgrok-annotation2"
+ tal:condition="not: iface/doc">
+ Use <span class="docgrok-pycode1">from <span
+ tal:replace="iface/path">x</span> import <span
+ tal:replace="iface/name">y</span></span> to make the
+ functionality of this class available in your application
+ or component.
+ </div>
</div>
- <div class="docgrok-annotation2"
- tal:condition="not: item/doc">
- Use <span class="docgrok-pycode1">from <span
- tal:replace="context/path">x</span> import <span
- tal:replace="item/name">y</span></span> to make this
- interface definition available in your application
- or component.
- </div>
+
</div>
- </div>
- <h2>Classes:</h2>
- <div class="docgrok-entry" tal:repeat="item view/getEntries">
- <div tal:condition="item/isclass">
- <div class="docgrok-pathvalue">
- class
- <a href=""
- tal:attributes="href string:${view/root_url}/docgrok/${item/url}"
- tal:content="item/name">
- ClassName
- </a>
+ <div class="docgrok-annotation2">
+ <span class="docgrok-description2">permissions:</span>
+ <div class="docgrok-annotation2">
+ read:
+ <span tal:content="item/read_perm">None</span>
</div>
- <div class="docgrok-annotation2"
- tal:condition="item/doc"
- tal:content="structure item/doc">
+ <div class="docgrok-annotation2">
+ write:
+ <span tal:content="item/write_perm">None</span>
</div>
- <div class="docgrok-annotation2"
- tal:condition="not: item/doc">
- Use <span class="docgrok-pycode1">from <span
- tal:replace="context/path">x</span> import <span
- tal:replace="item/name">y</span></span> to make the
- functionality of this class available in your application
- or component.
- </div>
</div>
+
+
</div>
--->
+
</div>
</div>
More information about the Checkins
mailing list