[Zope-dev] Re: weak examples, weak exploits

Evan Simpson evan@4-am.com
Mon, 23 Jun 2003 14:23:21 -0500


Casey Duncan wrote:
> I would be in favor of making the Examples "opt-in" like the Zope tutorial. It 
> seems silly to have it in evey ZODB by default. Make people add it if they 
> want it.

Many, many moons ago I created evan-examples-branch, which allows 
individual Products to offer sample code without (magically or 
otherwise) forcing them upon the user.  I'd love to see it revived, 
perhaps as "Examples/Optional Extras" in order to cover the Hurt system 
as well.

The basic idea is to look for an XML manifest file 'examples/index.xml' 
in each Product.  It probably wouldn't be very hard to use ZConfig 
instead of XML.  Here is the PageTemplates index.xml:

<example name="Assorted Examples">
   <description>
This is a set of examples of the use of page templates.
It includes examples of batching, macros, and trees.
   </description>
   <payload>
     <import file="zpt_examples.zexp"/>
   </payload>
   <view url="zpt_examples"/>
</example>

<!-- This file can contain any number of examples.

Each one consists of an <example> with a 'name' attribute,
containing exactly one <description>.  The name and description
are displayed in the Examples page.  <description> can have a
'format' attribute set to 'plain' (the default), 'stx' (structured
text), or 'html'.

An <example> can contain <payload> elements.  Each <payload> can
contain any number of <import>, <execute>, and <call> elements.
These are processed in order when an example is selected from the
Examples page.  <import> must have a 'file' attribute that names
a file in the 'examples' directory to be imported.  <execute> must
have a 'file' attribute that names a file to be run with execfile.
<call> must have a 'path' attribute that gives the path to a Zope
object to be called.

An <example> can contain at most one <view> element.  The 'url'
attribute of a <view> is the URL to view after all <payload> elements have
been processed. This URL can be relative to the current folder.

-->

Cheers,

Evan @ 4-am