[Checkins] SVN: Sandbox/ulif/grok-adminui-experimental/src/grok/ Functional docgrok tests.

Uli Fouquet uli at gnufix.de
Mon Aug 27 20:58:23 EDT 2007


Log message for revision 79302:
  Functional docgrok tests.

Changed:
  U   Sandbox/ulif/grok-adminui-experimental/src/grok/admin/view.py
  A   Sandbox/ulif/grok-adminui-experimental/src/grok/ftests/admin/apackage/
  A   Sandbox/ulif/grok-adminui-experimental/src/grok/ftests/admin/apackage/__init__.py
  A   Sandbox/ulif/grok-adminui-experimental/src/grok/ftests/admin/apackage/module1.py
  A   Sandbox/ulif/grok-adminui-experimental/src/grok/ftests/admin/docgrok.py

-=-
Modified: Sandbox/ulif/grok-adminui-experimental/src/grok/admin/view.py
===================================================================
--- Sandbox/ulif/grok-adminui-experimental/src/grok/admin/view.py	2007-08-27 21:56:12 UTC (rev 79301)
+++ Sandbox/ulif/grok-adminui-experimental/src/grok/admin/view.py	2007-08-28 00:58:22 UTC (rev 79302)
@@ -66,10 +66,11 @@
 
     def update(self, inspectapp=None, application=None):
         if inspectapp is not None:
-            self.redirect(self.url("docgrok") + "/%s/index"%(application.replace('.','/'),))
+            self.redirect(self.url("docgrok") + "/%s/index"%(
+                application.replace('.','/'),))
         return 
 
-    def render(self, application, name, inspectapp=None):
+    def render(self, application, name):
         if name is None or name == "":
             self.redirect(self.url(self.context))
             return
@@ -580,12 +581,14 @@
                 entry['isfunction'] = True
                 if hasattr(obj, 'getSignature'):
                     entry['signature'] = obj.getSignature()
-            elif (isinstance(obj,Module) and
+            elif (isinstance(obj, Module) and
                   os.path.basename(obj.getFileName()) in
                     ['__init.py__', '__init__.pyc', '__init__.pyo']):
                 entry['ispackage'] = True
-            elif isinstance(obj,Module):
+            elif isinstance(obj, Module):
                 entry['ismodule'] = True
+            elif isinstance(obj, InterfaceClass):
+                entry['isinterface'] = True
             entries.append(entry)
 
         entries.sort(lambda x, y: cmp(x['name'], y['name']))

Added: Sandbox/ulif/grok-adminui-experimental/src/grok/ftests/admin/apackage/__init__.py
===================================================================

Added: Sandbox/ulif/grok-adminui-experimental/src/grok/ftests/admin/apackage/module1.py
===================================================================
--- Sandbox/ulif/grok-adminui-experimental/src/grok/ftests/admin/apackage/module1.py	                        (rev 0)
+++ Sandbox/ulif/grok-adminui-experimental/src/grok/ftests/admin/apackage/module1.py	2007-08-28 00:58:22 UTC (rev 79302)
@@ -0,0 +1,17 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (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.
+#
+##############################################################################
+
+class Klass(object):
+    """A class.
+    """

Added: Sandbox/ulif/grok-adminui-experimental/src/grok/ftests/admin/docgrok.py
===================================================================
--- Sandbox/ulif/grok-adminui-experimental/src/grok/ftests/admin/docgrok.py	                        (rev 0)
+++ Sandbox/ulif/grok-adminui-experimental/src/grok/ftests/admin/docgrok.py	2007-08-28 00:58:22 UTC (rev 79302)
@@ -0,0 +1,98 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (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.
+#
+##############################################################################
+"""
+=================================
+DocGrok: a class browser for Grok
+=================================
+
+DocGrok offers an extensible class browser for packages, modules,
+classes and similar things. To use it in your own application see
+``docgrok.txt`` in the ``grok.admin`` package.
+
+Here only the functionality as a class browser for the admin-UI is
+covered.
+
+Overview page
+-------------
+
+When we go to the documentation section, we should get an overview:
+
+  >>> from zope.testbrowser.testing import Browser
+  >>> browser = Browser()
+  >>> browser.addHeader('Authorization', 'Basic mgr:mgrpw')
+  >>> browser.open('http://localhost/')
+  >>> browser.getLink('Documentation').click()
+  >>> print browser.contents
+  <html xmlns="http://www.w3.org/1999/xhtml">
+  ... Welcome to DocGrok...
+
+The overview offers us direct links to the zope package,
+
+  >>> link = browser.getLink('browse the zope package')
+  >>> link
+  <Link text='browse the zope package' url='http://localhost/docgrok/zope'>
+
+the grok package,
+
+  >>> link = browser.getLink('browse the grok package')
+  >>> link
+  <Link text='browse the grok package' url='http://localhost/docgrok/grok'>
+
+a link to the internal object browser, which is different from the
+class browser, and shows the ZODB root:
+
+  >>> link = browser.getLink('ZODB root folder')
+  >>> link
+  <Link text='ZODB root folder' url='http://localhost/@@inspect.html'>
+  
+There are several things, that can be displayed by the class
+browser. We start with packages.
+
+
+DocGrok for packages
+--------------------
+
+We placed a package in the ``apackage`` directory. Let's try to fetch
+documentation for it. We form a URL string, that contains the
+package's dotted name with dots replaced by slashes:
+
+  >>> pkg_dotted_name = __name__.rsplit('.',1)[0]
+  >>> url_path = 'http://localhost/docgrok/%s/apackage' % (
+  ...    pkg_dotted_name.replace('.', '/'))
+  >>> browser.open(url_path)
+
+Is it the documentation of the ``apackage`` package?
+
+  >>> print browser.contents
+  <html xmlns="http://www.w3.org/1999/xhtml">
+  ...
+  ...<span><a ...>.apackage</a></span>...
+  ...
+  ...(Python Package)...
+  ...
+
+Okay. In the page top we should have links to the various parent
+packages contained in the dotted name of the examined package:
+
+  >>> browser.getLink('grok')
+  <Link text='grok' url='http://localhost/docgrok/grok'>
+
+  >>> browser.getLink('ftests')
+  <Link text='.ftests' url='http://localhost/docgrok/grok/ftests'>
+
+and so on.
+
+
+
+"""



More information about the Checkins mailing list