[Zope-CVS] SVN: zope.tutorial/trunk/ Import initial code.

Stephan Richter srichter at cosmos.phy.tufts.edu
Sat Nov 12 13:29:16 EST 2005


Log message for revision 40074:
  Import initial code.
  

Changed:
  A   zope.tutorial/trunk/
  A   zope.tutorial/trunk/SETUP.cfg
  A   zope.tutorial/trunk/__init__.py
  A   zope.tutorial/trunk/browser/
  A   zope.tutorial/trunk/browser/__init__.py
  A   zope.tutorial/trunk/browser/configure.zcml
  A   zope.tutorial/trunk/browser/tutorial.pt
  A   zope.tutorial/trunk/configure.zcml
  A   zope.tutorial/trunk/directives.txt
  A   zope.tutorial/trunk/interfaces.py
  A   zope.tutorial/trunk/meta.zcml
  A   zope.tutorial/trunk/metaconfigure.py
  A   zope.tutorial/trunk/metadirectives.py
  A   zope.tutorial/trunk/selenium/
  A   zope.tutorial/trunk/selenium.py
  A   zope.tutorial/trunk/tests.py
  A   zope.tutorial/trunk/tutorial-configure.zcml
  A   zope.tutorial/trunk/tutorial-meta.zcml
  A   zope.tutorial/trunk/tutorial.py
  A   zope.tutorial/trunk/tutorials.zcml

-=-
Added: zope.tutorial/trunk/SETUP.cfg
===================================================================
--- zope.tutorial/trunk/SETUP.cfg	2005-11-12 18:28:13 UTC (rev 40073)
+++ zope.tutorial/trunk/SETUP.cfg	2005-11-12 18:29:16 UTC (rev 40074)
@@ -0,0 +1,5 @@
+# Tell zpkg how to install the ZCML slugs.
+
+<data-files zopeskel/etc/package-includes>
+  tutorial-*.zcml
+</data-files>

Added: zope.tutorial/trunk/__init__.py
===================================================================
--- zope.tutorial/trunk/__init__.py	2005-11-12 18:28:13 UTC (rev 40073)
+++ zope.tutorial/trunk/__init__.py	2005-11-12 18:29:16 UTC (rev 40074)
@@ -0,0 +1 @@
+# Make a package


Property changes on: zope.tutorial/trunk/__init__.py
___________________________________________________________________
Name: svn:eol-style
   + native

Added: zope.tutorial/trunk/browser/__init__.py
===================================================================
--- zope.tutorial/trunk/browser/__init__.py	2005-11-12 18:28:13 UTC (rev 40073)
+++ zope.tutorial/trunk/browser/__init__.py	2005-11-12 18:29:16 UTC (rev 40074)
@@ -0,0 +1 @@
+# Make a package


Property changes on: zope.tutorial/trunk/browser/__init__.py
___________________________________________________________________
Name: svn:eol-style
   + native

Added: zope.tutorial/trunk/browser/configure.zcml
===================================================================
--- zope.tutorial/trunk/browser/configure.zcml	2005-11-12 18:28:13 UTC (rev 40073)
+++ zope.tutorial/trunk/browser/configure.zcml	2005-11-12 18:29:16 UTC (rev 40074)
@@ -0,0 +1,10 @@
+<configure
+    xmlns="http://namespaces.zope.org/browser"
+    xmlns:zope="http://namespaces.zope.org/zope"
+    i18n_domain="zope">
+
+  <resourceDirectory
+      name="selenium-driver"
+      directory="../selenium/javascript" />
+
+</configure>


Property changes on: zope.tutorial/trunk/browser/configure.zcml
___________________________________________________________________
Name: svn:eol-style
   + native

Added: zope.tutorial/trunk/browser/tutorial.pt
===================================================================
--- zope.tutorial/trunk/browser/tutorial.pt	2005-11-12 18:28:13 UTC (rev 40073)
+++ zope.tutorial/trunk/browser/tutorial.pt	2005-11-12 18:29:16 UTC (rev 40074)
@@ -0,0 +1,64 @@
+<html>
+  <head>
+    <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
+      <title>Online Tutorial Viewer</title>
+      <link rel="stylesheet" type="text/css" href="selenium.css" />
+      <script
+          language="JavaScript" type="text/javascript"
+          src="jsunit/app/jsUnitCore.js"></script>
+      <script
+          language="JavaScript" type="text/javascript"
+          src="xmlextras.js"></script>
+      <script
+          language="JavaScript" type="text/javascript"
+          src="selenium-browserbot.js"></script>
+      <script
+          language="JavaScript" type="text/javascript"
+          src="selenium-api.js"></script>
+      <script
+          language="JavaScript" type="text/javascript"
+          src="selenium-commandhandlers.js"></script>
+      <script
+          language="JavaScript" type="text/javascript"
+          src="selenium-executionloop.js"></script>
+      <script
+          language="JavaScript" type="text/javascript"
+          src="selenium-seleneserunner.js"></script>
+      <script
+          language="JavaScript" type="text/javascript"
+          src="selenium-logging.js"></script>
+      <script
+          language="JavaScript" type="text/javascript"
+          src="htmlutils.js"></script>
+      <script
+          language="JavaScript" type="text/javascript"
+          src="xpath.js"></script>
+      <script
+          language="JavaScript" type="text/javascript"
+          src="user-extensions.js"></script>
+  </head>
+
+  <body onLoad="runTest()">
+
+    <table border="1" style="height: 100%;">
+      <tr>
+        <td width="50%" height="30%">
+          <form action="">
+            <label id="context" name="context"></label>
+          </form>
+        </td>
+        <td width="50%" height="30%">
+          <b>Last Four Commands</b><br/>
+          <div id="commandList"></div>
+        </td>
+      </tr>
+      <tr>
+        <td colspan="2" height="70%">
+          <iframe name="myiframe" id="myiframe" src=""
+                  height="100%" width="100%"></iframe>
+        </td>
+      </tr>
+    </table>
+
+  </body>
+</html>


Property changes on: zope.tutorial/trunk/browser/tutorial.pt
___________________________________________________________________
Name: svn:eol-style
   + native

Added: zope.tutorial/trunk/configure.zcml
===================================================================
--- zope.tutorial/trunk/configure.zcml	2005-11-12 18:28:13 UTC (rev 40073)
+++ zope.tutorial/trunk/configure.zcml	2005-11-12 18:29:16 UTC (rev 40074)
@@ -0,0 +1,21 @@
+<configure
+    xmlns="http://namespaces.zope.org/zope"
+    i18n_domain="zope">
+
+  <!-- ++tutorials++ Namespace Registration -->
+
+  <view
+      name="tutorials" type="*"
+      provides="zope.app.traversing.interfaces.ITraversable" for="*"
+      factory=".tutorial.tutorialsNamespace"
+      />
+
+  <adapter
+      name="tutorials"
+      provides="zope.app.traversing.interfaces.ITraversable" for="*"
+      factory=".tutorial.tutorialsNamespace"
+      />
+
+  <include package=".browser" />
+
+</configure>


Property changes on: zope.tutorial/trunk/configure.zcml
___________________________________________________________________
Name: svn:eol-style
   + native

Added: zope.tutorial/trunk/directives.txt
===================================================================
--- zope.tutorial/trunk/directives.txt	2005-11-12 18:28:13 UTC (rev 40073)
+++ zope.tutorial/trunk/directives.txt	2005-11-12 18:29:16 UTC (rev 40074)
@@ -0,0 +1,37 @@
+=============================
+The `zope:tutorial` Directive
+=============================
+
+This directive allows you to register new tutorials with the tutorial
+manager. Before we can register a new tutoral, we need to load the
+meta-configuration:
+
+  >>> from zope.configuration import xmlconfig
+  >>> import zope.tutorial
+  >>> context = xmlconfig.file('meta.zcml', zope.tutorial)
+
+Now we can run the directive. First, let's make sure that no tutorials have
+been registered yet:
+
+  >>> from zope.app import zapi
+  >>> from zope.tutorial import interfaces
+  >>> list(zapi.getUtilitiesFor(interfaces.ITutorial))
+  []
+
+Now run the registration code:
+
+  >>> context = xmlconfig.string('''
+  ...     <configure
+  ...         xmlns="http://namespaces.zope.org/zope">
+  ...       <tutorial
+  ...           name="zope_tutorial_directive"
+  ...           title="zope:tutorial Directive"
+  ...           path="directives.txt"
+  ...           />
+  ...     </configure>''', context)
+
+Note that this file is not really a functional test-browser test, so it would
+not actually work in the Web interface. Now the tutorial is available:
+
+  >>> list(zapi.getUtilitiesFor(interfaces.ITutorial))
+  [(u'zope_tutorial_directive', )]


Property changes on: zope.tutorial/trunk/directives.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Added: zope.tutorial/trunk/interfaces.py
===================================================================
--- zope.tutorial/trunk/interfaces.py	2005-11-12 18:28:13 UTC (rev 40073)
+++ zope.tutorial/trunk/interfaces.py	2005-11-12 18:29:16 UTC (rev 40074)
@@ -0,0 +1,48 @@
+##############################################################################
+#
+# Copyright (c) 2005 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.
+#
+##############################################################################
+"""Tutorials-related Interfaces
+
+$Id$
+"""
+__docformat__ = "reStructuredText"
+
+import zope.interface
+import zope.schema
+from zope.app.container import interfaces
+
+
+class ITutorialManager(interfaces.IReadContainer):
+    """Tutorial Manager
+
+    The tutorial manager is used as an entry point to the tutorials
+    application.
+    """
+
+
+class ITutorial(zope.interface.Interface):
+    """Tutorial
+
+    Tutorials are objects that provide a tutorial via the browser to a
+    user. They use functional test-browser tests for their content.
+    """
+
+    title = zope.schema.TextLine(
+        title=u'Title',
+        description=u'The title of the tutorial.',
+        required=True)
+
+    filename = zope.schema.URI(
+        title=u'File name',
+        description=u'Path to the file used for the tutorial',
+        required=True)


Property changes on: zope.tutorial/trunk/interfaces.py
___________________________________________________________________
Name: svn:eol-style
   + native

Added: zope.tutorial/trunk/meta.zcml
===================================================================
--- zope.tutorial/trunk/meta.zcml	2005-11-12 18:28:13 UTC (rev 40073)
+++ zope.tutorial/trunk/meta.zcml	2005-11-12 18:29:16 UTC (rev 40074)
@@ -0,0 +1,14 @@
+<configure
+    xmlns:meta="http://namespaces.zope.org/meta"
+    xmlns:zcml="http://namespaces.zope.org/zcml"
+    >
+
+  <meta:directive
+      namespace="http://namespaces.zope.org/zope"
+      name="tutorial"
+      schema=".metadirectives.ITutorialDirective"
+      handler=".metaconfigure.tutorial" />
+
+  <meta:provides feature="tutorials" />
+
+</configure>


Property changes on: zope.tutorial/trunk/meta.zcml
___________________________________________________________________
Name: svn:eol-style
   + native

Added: zope.tutorial/trunk/metaconfigure.py
===================================================================
--- zope.tutorial/trunk/metaconfigure.py	2005-11-12 18:28:13 UTC (rev 40073)
+++ zope.tutorial/trunk/metaconfigure.py	2005-11-12 18:29:16 UTC (rev 40074)
@@ -0,0 +1,30 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 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.
+#
+##############################################################################
+"""Meta-Configuration Handler for the ``zope:tutorial`` directive.
+
+$Id: $
+"""
+__docformat__ = 'restructuredtext'
+
+from zope.tutorial import tutorial, interfaces
+from zope.app.component import metaconfigure
+
+def tutorial(_context, name, title, path):
+    """Register a tutorial"""
+
+    metaconfigure.utility(
+        _context,
+        provides = interfaces.ITutorial,
+        component = tutorial.Tutorial(title, path),
+        name = name)


Property changes on: zope.tutorial/trunk/metaconfigure.py
___________________________________________________________________
Name: svn:eol-style
   + native

Added: zope.tutorial/trunk/metadirectives.py
===================================================================
--- zope.tutorial/trunk/metadirectives.py	2005-11-12 18:28:13 UTC (rev 40073)
+++ zope.tutorial/trunk/metadirectives.py	2005-11-12 18:29:16 UTC (rev 40074)
@@ -0,0 +1,40 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 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.
+#
+##############################################################################
+"""Schema for the ``zope:tutorial`` directive
+
+$Id: $
+"""
+__docformat__ = 'restructuredtext'
+
+import zope.interface
+import zope.schema
+from zope.configuration import fields
+
+class ITutorialDirective(zope.interface.Interface):
+    """Register a new Tutorial"""
+
+    name = zope.schema.BytesLine(
+        title=u"Tutrial Name",
+        description=u"Name of the tutorial as it will appear in the URL.",
+        required=True)
+
+    title = fields.MessageID(
+        title=u"Title",
+        description=u"Provides a title for the chapter.",
+        required=True)
+
+    path = fields.Path(
+        title=u"Path to File",
+        description=u"Path to the file that contains the tutorial content.",
+        required=False)


Property changes on: zope.tutorial/trunk/metadirectives.py
___________________________________________________________________
Name: svn:eol-style
   + native

Added: zope.tutorial/trunk/selenium.py
===================================================================
--- zope.tutorial/trunk/selenium.py	2005-11-12 18:28:13 UTC (rev 40073)
+++ zope.tutorial/trunk/selenium.py	2005-11-12 18:29:16 UTC (rev 40074)
@@ -0,0 +1,77 @@
+##############################################################################
+#
+# Copyright (c) 2005 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.
+#
+##############################################################################
+"""Selenium-based Test Browser
+
+$Id$
+"""
+__docformat__ = "reStructuredText"
+import zope.interface
+
+#class SeleniumBrowser(SetattrErrorsMixin):
+#    """A web user agent."""
+#    zope.interface.implements(interfaces.IBrowser)
+#
+#    _contents = None
+#    _counter = 0
+#
+#    def __init__(self, url=None, mech_browser=None):
+#        if mech_browser is None:
+#            mech_browser = mechanize.Browser()
+#        self.mech_browser = mech_browser
+#        if url is not None:
+#            self.open(url)
+#        self.timer = PystoneTimer()
+#        self._enable_setattr_errors = True
+#
+#    @property
+#    def url(self):
+#        """See zope.testbrowser.interfaces.IBrowser"""
+#        return self.mech_browser.geturl()
+#
+#    @property
+#    def isHtml(self):
+#        """See zope.testbrowser.interfaces.IBrowser"""
+#        return self.mech_browser.viewing_html()
+#
+#    @property
+#    def title(self):
+#        """See zope.testbrowser.interfaces.IBrowser"""
+#        return self.mech_browser.title()
+#
+#    @property
+#    def contents(self):
+#        """See zope.testbrowser.interfaces.IBrowser"""
+#        if self._contents is not None:
+#            return self._contents
+#        response = self.mech_browser.response()
+#        old_location = response.tell()
+#        response.seek(0)
+#        for line in iter(lambda: response.readline().strip(), ''):
+#            pass
+#        self._contents = response.read()
+#        response.seek(old_location)
+#        return self._contents
+#
+#    @property
+#    def headers(self):
+#        """See zope.testbrowser.interfaces.IBrowser"""
+#        return self.mech_browser.response().info()
+#
+#    def open(self, url, data=None):
+#        """See zope.testbrowser.interfaces.IBrowser"""
+#        self._start_timer()
+#        self.mech_browser.open(url, data)
+#        self._stop_timer()
+#        self._changed()
+#


Property changes on: zope.tutorial/trunk/selenium.py
___________________________________________________________________
Name: svn:eol-style
   + native

Added: zope.tutorial/trunk/tests.py
===================================================================
--- zope.tutorial/trunk/tests.py	2005-11-12 18:28:13 UTC (rev 40073)
+++ zope.tutorial/trunk/tests.py	2005-11-12 18:29:16 UTC (rev 40074)
@@ -0,0 +1,34 @@
+##############################################################################
+#
+# Copyright (c) 2004 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.
+#
+##############################################################################
+"""Viewlet tests
+
+$Id: tests.py 39461 2005-10-15 10:45:13Z srichter $
+"""
+__docformat__ = 'restructuredtext'
+
+import unittest
+from zope.testing import doctest
+from zope.testing.doctestunit import DocFileSuite
+from zope.app.testing import setup
+
+def test_suite():
+    return unittest.TestSuite((
+        DocFileSuite('directives.txt',
+                     setUp=setup.SetUp, tearDown=setup.TearDown,
+                     optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
+                     ),
+        ))
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')


Property changes on: zope.tutorial/trunk/tests.py
___________________________________________________________________
Name: svn:eol-style
   + native

Added: zope.tutorial/trunk/tutorial-configure.zcml
===================================================================
--- zope.tutorial/trunk/tutorial-configure.zcml	2005-11-12 18:28:13 UTC (rev 40073)
+++ zope.tutorial/trunk/tutorial-configure.zcml	2005-11-12 18:29:16 UTC (rev 40074)
@@ -0,0 +1 @@
+<include package="zope.tutorial" />


Property changes on: zope.tutorial/trunk/tutorial-configure.zcml
___________________________________________________________________
Name: svn:eol-style
   + native

Added: zope.tutorial/trunk/tutorial-meta.zcml
===================================================================
--- zope.tutorial/trunk/tutorial-meta.zcml	2005-11-12 18:28:13 UTC (rev 40073)
+++ zope.tutorial/trunk/tutorial-meta.zcml	2005-11-12 18:29:16 UTC (rev 40074)
@@ -0,0 +1 @@
+<include package="zope.tutorial"  file="meta.zcml" />


Property changes on: zope.tutorial/trunk/tutorial-meta.zcml
___________________________________________________________________
Name: svn:eol-style
   + native

Added: zope.tutorial/trunk/tutorial.py
===================================================================
--- zope.tutorial/trunk/tutorial.py	2005-11-12 18:28:13 UTC (rev 40073)
+++ zope.tutorial/trunk/tutorial.py	2005-11-12 18:29:16 UTC (rev 40074)
@@ -0,0 +1,65 @@
+##############################################################################
+#
+# Copyright (c) 2005 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.
+#
+##############################################################################
+"""Tutorial Manager Implementation
+
+$Id$
+"""
+__docformat__ = "reStructuredText"
+
+import zope.interface
+from zope.app.apidoc import utilities
+from zope.app import location
+
+from zope.tutorial import interfaces
+
+
+class TutorialManager(utilities.ReadContainerBase):
+    """TutorialManager"""
+
+    zope.interface.implements(interfaces.ITutorialManager,
+                              location.interfaces.ILocation)
+
+    def __init__(self, parent):
+        self.__parent__ = parent
+        self.__name__ = '++tutorials++'
+
+    def get(self, key, default=None):
+        """See zope.app.container.interfaces.IReadContainer"""
+        utility = zapi.queryUtility(ITutorial, key, default)
+        if utility != default:
+            location.locate(utility, self, key)
+        return utility
+
+    def items(self):
+        """See zope.app.container.interfaces.IReadContainer"""
+        items = list(zapi.getUtilitiesFor(ITutorial))
+        items.sort()
+        utils = []
+        for key, value in items:
+            location.locate(value, self, key)
+            utils.append((key, value))
+        return utils
+
+
+class tutorialsNamespace(object):
+    """Used to traverse the `++tutorials++` namespace"""
+
+    def __init__(self, ob, request=None):
+        self.tutorialManager = TutorialManager(ob)
+
+    def traverse(self, name, ignore):
+        if name == '':
+            return self.tutorialManager
+        else:
+            return self.tutorialManager[key]


Property changes on: zope.tutorial/trunk/tutorial.py
___________________________________________________________________
Name: svn:eol-style
   + native

Added: zope.tutorial/trunk/tutorials.zcml
===================================================================
--- zope.tutorial/trunk/tutorials.zcml	2005-11-12 18:28:13 UTC (rev 40073)
+++ zope.tutorial/trunk/tutorials.zcml	2005-11-12 18:29:16 UTC (rev 40074)
@@ -0,0 +1,14 @@
+<configure
+    xmlns="http://namespaces.zope.org/zope"
+    i18n_domain="zope">
+
+  <configure package="zope.testbrowser">
+
+    <tutorial
+        name="testbrowser"
+        title="Test Browser Features"
+        path="README.txt" />
+
+  </configure>
+
+</configure>


Property changes on: zope.tutorial/trunk/tutorials.zcml
___________________________________________________________________
Name: svn:eol-style
   + native



More information about the Zope-CVS mailing list