[Checkins] SVN: z3ext.layout/trunk/ Add narrative documentation for this package. Still unfinished, but ready for review.

Dan Korostelev nadako at gmail.com
Fri Oct 30 11:41:31 EDT 2009


Log message for revision 105391:
  Add narrative documentation for this package. Still unfinished, but ready for review.

Changed:
  U   z3ext.layout/trunk/buildout.cfg
  A   z3ext.layout/trunk/docs/
  A   z3ext.layout/trunk/docs/Makefile
  A   z3ext.layout/trunk/docs/README.txt
  A   z3ext.layout/trunk/docs/conf.py

-=-
Modified: z3ext.layout/trunk/buildout.cfg
===================================================================
--- z3ext.layout/trunk/buildout.cfg	2009-10-30 13:50:34 UTC (rev 105390)
+++ z3ext.layout/trunk/buildout.cfg	2009-10-30 15:41:31 UTC (rev 105391)
@@ -1,6 +1,6 @@
 [buildout]
 develop = .
-parts = test coverage-test coverage-report
+parts = test coverage-test coverage-report sphinx
 
 [test]
 recipe = zc.recipe.testrunner
@@ -16,3 +16,9 @@
 eggs = z3c.coverage
 scripts = coverage=coverage-report
 arguments = ('coverage', 'coverage/report')
+
+[sphinx]
+recipe = zc.recipe.egg
+eggs =
+  sphinx
+  docutils


Property changes on: z3ext.layout/trunk/docs
___________________________________________________________________
Added: svn:ignore
   + _build


Added: z3ext.layout/trunk/docs/Makefile
===================================================================
--- z3ext.layout/trunk/docs/Makefile	                        (rev 0)
+++ z3ext.layout/trunk/docs/Makefile	2009-10-30 15:41:31 UTC (rev 105391)
@@ -0,0 +1,89 @@
+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS    =
+SPHINXBUILD   = ../bin/sphinx-build
+PAPER         =
+BUILDDIR      = _build
+
+# Internal variables.
+PAPEROPT_a4     = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS   = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+
+.PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest
+
+help:
+	@echo "Please use \`make <target>' where <target> is one of"
+	@echo "  html      to make standalone HTML files"
+	@echo "  dirhtml   to make HTML files named index.html in directories"
+	@echo "  pickle    to make pickle files"
+	@echo "  json      to make JSON files"
+	@echo "  htmlhelp  to make HTML files and a HTML help project"
+	@echo "  qthelp    to make HTML files and a qthelp project"
+	@echo "  latex     to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+	@echo "  changes   to make an overview of all changed/added/deprecated items"
+	@echo "  linkcheck to check all external links for integrity"
+	@echo "  doctest   to run all doctests embedded in the documentation (if enabled)"
+
+clean:
+	-rm -rf $(BUILDDIR)/*
+
+html:
+	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
+	@echo
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
+
+dirhtml:
+	$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
+	@echo
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
+
+pickle:
+	$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
+	@echo
+	@echo "Build finished; now you can process the pickle files."
+
+json:
+	$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
+	@echo
+	@echo "Build finished; now you can process the JSON files."
+
+htmlhelp:
+	$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
+	@echo
+	@echo "Build finished; now you can run HTML Help Workshop with the" \
+	      ".hhp project file in $(BUILDDIR)/htmlhelp."
+
+qthelp:
+	$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
+	@echo
+	@echo "Build finished; now you can run "qcollectiongenerator" with the" \
+	      ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
+	@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/z3extpreferences.qhcp"
+	@echo "To view the help file:"
+	@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/z3extpreferences.qhc"
+
+latex:
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+	@echo
+	@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
+	@echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
+	      "run these through (pdf)latex."
+
+changes:
+	$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
+	@echo
+	@echo "The overview file is in $(BUILDDIR)/changes."
+
+linkcheck:
+	$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
+	@echo
+	@echo "Link check complete; look for any errors in the above output " \
+	      "or in $(BUILDDIR)/linkcheck/output.txt."
+
+doctest:
+	$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
+	@echo "Testing of doctests in the sources finished, look at the " \
+	      "results in $(BUILDDIR)/doctest/output.txt."

Added: z3ext.layout/trunk/docs/README.txt
===================================================================
--- z3ext.layout/trunk/docs/README.txt	                        (rev 0)
+++ z3ext.layout/trunk/docs/README.txt	2009-10-30 15:41:31 UTC (rev 105391)
@@ -0,0 +1,323 @@
+Browser layout and page system
+==============================
+
+The ``z3ext.layout`` package implements a flexible way to create browser pages
+with higly customizable layouts and dipsplay logic.
+
+This package registers browser pages as (context, request) adapters, so they
+are simple views in a zope world. But the pages created by this package are very
+smart. The main feature is extremely powerful content/layout separation mechanism,
+including support for multiple layouts for different types of content, views and
+skins, nested layouts, pluggable templates etc.
+
+In the following chapters, we well use two main terms:
+
+* pagelet - the "content" part of a browser page.
+* layout - the layout in which pagelet is rendered.
+
+
+Basic usage
+-----------
+
+This chapter will show you how to create a page from template, class or both,
+and how to define a layout for them.
+
+Note, that we will use ZCML directives in the "z3ext" namespace, to make them
+available, you need to define that namespace pointing to "http://namespaces.zope.org/z3ext"
+in your ``configure.zcml`` file. Example::
+
+  <configure
+      xmlns="http://namespaces.zope.org/zope"
+      xmlns:z3ext="http://namespaces.zope.org/z3ext"
+      >
+
+    ... some directives in the "z3ext" namespace"
+
+  </configure>
+
+
+Creating pages
+~~~~~~~~~~~~~~
+
+As said above, the page consist of the "pagelet" and "layout", in this chapter
+we will talk about creating pagelets. To create a pagelet, we use the
+``z3ext:pagelet`` ZCML directive. 
+
+
+Providing only a template
++++++++++++++++++++++++++
+
+One of the simplest cases is when you want to create a templated page for a
+content type, let's show how it's done::
+
+  <z3ext:pagelet
+    for=".interfaces.IContent"
+    name="index.html"
+    template="content.pt"
+    />
+
+In the example above, we created a pagelet named "index.html" for objects
+providing "IContent" interface using template in the "content.pt" file. Note,
+that did not specify access permission for this pagelet, that means that this
+pagelet is public, so it will be accessible without restrictions.
+
+When accessed, this pagelet will be rendered using default unnamed layout, or
+if layout can not be found, it will be rendered without any layout. We'll
+talk about layouts a bit later.
+
+
+Providing a template and a class
+++++++++++++++++++++++++++++++++
+
+If you want to provide some logic in the pagelet, such as getting needed values
+or processing some request arguments, you can provide a mix-in class. z3ext
+pagelet system uses the update/render pattern, so pagelet classes have the
+"update" method that performs required actions, and the "render" method that
+does the rendering of pagelet.
+
+The default "render" method does rendering of the pagelet's template and the
+default "update" method does nothing. So, if we want to use a template, but
+include some logic before template is rendered, we need to provide own "update"
+method.
+
+Let's create a "smart" helloworld-type pagelet class::
+
+  class GreeterPage(object):
+  
+      def update(self):
+          self.who = self.request.get('who', 'World')
+
+As you can see, it sets the "who" attribute to itself, getting the data from
+the request. From a template, it can be accessed via "view" variable::
+
+  <p>
+    Hello, <span tal:replace="view/who" />!
+  </p>
+
+Finally, register the pagelet with ZCML directive, passing the mix-in class
+as the "class" argument::
+
+  <z3ext:pagelet
+    for="*"
+    name="hello.html"
+    template="hello.pt"
+    class=".GreeterPage"
+    />
+
+Note that in the example above we used asterisk ("*" sign) in "for" argument,
+that means that the pagelet is registered for any type of object.
+
+Providing only a class
+++++++++++++++++++++++
+
+There is two cases when you want to only provide a class and don't provide any
+template for a pagelet:
+
+1. You want to implement custom rendering.
+2. You want template to be provided separately, in other place or be dependent
+   on a browser skin/layer.
+
+z3ext pagelets support both.
+
+In a first case, you need to provide a class with custom "render" method that
+should return a string ready to include in a layout.
+
+Let's give an example of such class::
+
+  class CustomRender(object):
+  
+      def render(self):
+          return u'<p>Hello world!</p>'
+
+This class doesn't need any templates, as it renders the ready-to-use HTML
+content. It can be registered without specifying the "template" argument::
+
+  <z3ext:pagelet
+    for="*"
+    name="hello2.html"
+    class=".CustomRenderPage"
+    />
+
+
+In a second case, when you want to provide template separately, you shouldn't
+override the "default" render behaviour and shouldn't provide a template when
+registering a pagelet.
+
+Let's use for example a "smart" greeter view class we used above::
+
+  class GreeterPage(object):
+  
+      def update(self):
+          self.who = self.request.get('who', 'World')
+
+But now, we'll register it without providing a template::
+
+  <z3ext:pagelet
+    for="*"
+    name="hello3.html"
+    class=".GreeterPage"
+    />
+
+What the default "render" implementation will do is try to search an unnamed
+pagelet for this pagelet and current request object.
+
+So, to register a template for the pagelet above, we need to register a
+templated pagelet passing this pagelet in the "for" argument, without specifying
+a name::
+
+  <z3ext:pagelet
+    for=".GreeterPage"
+    template="hello.pt"
+    />
+
+As you may notice, this trick gives even more control of rendering, because you
+can provide custom logic for that "template pagelet", giving another class via
+"class" argument. This can be extremely useful when you want to provide additional
+logic when rendering third-party pagelets in your skins.
+
+
+Creating layouts
+~~~~~~~~~~~~~~~~
+
+This chapter describes the layouts mechanism and ways of defining layouts.
+
+In the previous chapter we described how to create differently rendered pagelets.
+But all pagelets, when accessed from a browser are renderd into some layout.
+
+Every web site nowadays has common look and feel thru all its pages, so it makes
+sense to define layout separately. Moreover, in complex web applications, some
+parts has different "sub-layout" inside one common layout. This is greatly
+supported by the ``z3ext.layout`` package.
+
+Basics
+++++++
+
+So, to define a layout, we use the another ZCML directive, named ``z3ext:layout``.
+By default, pagelets use unnamed layout, registered either for a pagelet, or
+content object, or both.
+
+What layout does is rendering a pagelet framed in some layout elements, so let's
+create such template. The pagelet is available as "view" variable in the template,
+so it can call its "render" method::
+
+  <html>
+   <head>
+    <title>Example layout</head>
+   </head>
+   <body tal:content="structure view/render">
+    Here comes the content...
+   </body>
+  </html> 
+
+Now let's register this template as a layout for our ``GreeterPage`` pagelet,
+that we created in previous chapter::
+
+  <z3ext:layout
+    view=".GreeterPage"
+    template="layout.pt"
+    />
+
+If we want to provide another layout for the same pagelet, but for different
+content type, we can register it specifying the "for" argument::
+
+  <z3ext:layout
+    for=".interfaces.ISomeContentMarker"
+    view=".GreeterPage"
+    template="layout2.pt"
+    />
+
+So, everything besides objects providing ``ISomeContentMarker`` will use
+"layout.pt" template and ``ISomeContentMarker`` objects will use "layout2.pt"
+template for the ``GreeterPage`` pagelet.
+
+
+Nested layouts
+++++++++++++++
+
+Very often we need to use several layouts for different pages that still have
+some common parent layout. Here nested named layouts come to help.
+
+In the previous section, we registered basic HTML structure as a layout for
+our pagelet. But let's imagine, that that basic HTML structure is required
+for all pages in our web portal, but one of pagelets, the ``GreeterPage`` needs
+additional layout needed for its presentation. To implement that, first, let's
+register our basic HTML structure as a layouts named "portal"::
+
+  <z3ext:layout
+    for="*"
+    name="portal"
+    template="layout.pt"
+    />
+
+That means exactly that for any object there's a layout named "portal" that uses
+the "layout.pt" template.
+
+Now, let's create a "sub-layout" template for our greeter page::
+
+  <div class="greeter" tal:content="structure view/render">
+    here comes content
+  </div>
+
+We register it for our ``GreeterPage`` just like we we did it first time,
+excepting that we specify additional argument - "layout" that is a name
+to a parent layout::
+
+  <z3ext:layout
+    view=".GreeterPage"
+    template="greeter_layout.pt"
+    layout="portal"
+    />
+
+So, now our greeter page will be rendered somewhat like this::
+
+  <html>
+   <head>
+    <title>Example layout</head>
+   </head>
+   <body>
+    <div class="greeter">
+     <p>
+      Hello, World!
+     </p>
+    </div>
+   </body>
+  </html> 
+
+The original pagelet template is rendered in its sub-layout which is rendered
+in its parent layout. The depth of nesting is not restricted, so you can create
+sub-sub-layouts and so on.
+
+.. note::
+
+  The ``z3ext.layout`` package has some default layout configuration defined in
+  its "configure.zcml" file. This configuration is used by the z3ext default
+  browser UI.
+
+  First, it defines a default unnamed layout with a template containing a
+  "div" element that wraps the content of a pagelet.
+  
+  Second, that unnamed layout has a parent layout named "viewspace" that also
+  adds its own wrapper HTML elements.
+  
+  Third, the "viewspace" layout has another parent layout named "workspace",
+  that, again adds more wrapper HTML elements.
+  
+  And finally, the "workspace" has the "portal" layout as its parent that
+  wraps the content with some HTML elements and renders status messages above.
+  
+  The "portal" layout uses the zope3 "standard_macros" concept to render itself,
+  so it will work with skins like "Rotterdam" or "Boston" from zope3. But if
+  you are not planning to integrate z3ext pagelets with those skins, you can
+  simply override the "portal" layout for your skin.
+  
+  The power in this is that you can override layout at any level for any pagelet
+  or content object, adding your own page elements or changing existing ones.
+
+
+Advanced usage
+--------------
+
+TODO:
+
+* full description of ZCML directives: pagelet, layout, pageletType
+* additional/custom layout logic (specifying mixin class for layouts).

Added: z3ext.layout/trunk/docs/conf.py
===================================================================
--- z3ext.layout/trunk/docs/conf.py	                        (rev 0)
+++ z3ext.layout/trunk/docs/conf.py	2009-10-30 15:41:31 UTC (rev 105391)
@@ -0,0 +1,194 @@
+# -*- coding: utf-8 -*-
+#
+# z3ext.preferences documentation build configuration file, created by
+# sphinx-quickstart on Wed Oct 28 17:04:08 2009.
+#
+# This file is execfile()d with the current directory set to its containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+import sys, os
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+#sys.path.append(os.path.abspath('.'))
+
+# -- General configuration -----------------------------------------------------
+
+# Add any Sphinx extension module names here, as strings. They can be extensions
+# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
+extensions = ['sphinx.ext.todo']
+
+# Add any paths that contain templates here, relative to this directory.
+#templates_path = ['_templates']
+
+# The suffix of source filenames.
+source_suffix = '.txt'
+
+# The encoding of source files.
+#source_encoding = 'utf-8'
+
+# The master toctree document.
+master_doc = 'README'
+
+# General information about the project.
+project = u'z3ext.layout'
+copyright = u'2009, Dan Korostelev'
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = '0'
+# The full version, including alpha/beta/rc tags.
+release = 'development'
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+#today_fmt = '%B %d, %Y'
+
+# List of documents that shouldn't be included in the build.
+#unused_docs = []
+
+# List of directories, relative to source directory, that shouldn't be searched
+# for source files.
+exclude_trees = ['_build']
+
+# The reST default role (used for this markup: `text`) to use for all documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+#add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# A list of ignored prefixes for module index sorting.
+#modindex_common_prefix = []
+
+
+# -- Options for HTML output ---------------------------------------------------
+
+# The theme to use for HTML and HTML Help pages.  Major themes that come with
+# Sphinx are currently 'default' and 'sphinxdoc'.
+html_theme = 'default'
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further.  For a list of options available for each theme, see the
+# documentation.
+#html_theme_options = {}
+
+# Add any paths that contain custom themes here, relative to this directory.
+#html_theme_path = []
+
+# The name for this set of Sphinx documents.  If None, it defaults to
+# "<project> v<release> documentation".
+#html_title = None
+
+# A shorter title for the navigation bar.  Default is the same as html_title.
+#html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+#html_logo = None
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+#html_favicon = None
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+#html_static_path = ['_static']
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+#html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+#html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#html_sidebars = {}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+#html_additional_pages = {}
+
+# If false, no module index is generated.
+#html_use_modindex = True
+
+# If false, no index is generated.
+#html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+#html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+#html_show_sourcelink = True
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it.  The value of this option must be the
+# base URL from which the finished HTML is served.
+#html_use_opensearch = ''
+
+# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = ''
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'z3extlayoutdoc'
+
+
+# -- Options for LaTeX output --------------------------------------------------
+
+# The paper size ('letter' or 'a4').
+#latex_paper_size = 'letter'
+
+# The font size ('10pt', '11pt' or '12pt').
+#latex_font_size = '10pt'
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title, author, documentclass [howto/manual]).
+latex_documents = [
+  ('index', 'z3extlayout.tex', u'z3ext.layout Documentation',
+   u'Dan Korostelev', 'manual'),
+]
+
+# The name of an image file (relative to this directory) to place at the top of
+# the title page.
+#latex_logo = None
+
+# For "manual" documents, if this is true, then toplevel headings are parts,
+# not chapters.
+#latex_use_parts = False
+
+# Additional stuff for the LaTeX preamble.
+#latex_preamble = ''
+
+# Documents to append as an appendix to all manuals.
+#latex_appendices = []
+
+# If false, no module index is generated.
+#latex_use_modindex = True


Property changes on: z3ext.layout/trunk/docs/conf.py
___________________________________________________________________
Added: svn:keywords
   + Id



More information about the checkins mailing list