[Checkins] SVN: z3c.talk/trunk/ - Initial setup of talks structure.
Stephan Richter
srichter at cosmos.phy.tufts.edu
Wed Oct 8 13:18:27 EDT 2008
Log message for revision 91909:
- Initial setup of talks structure.
- Added Z3CForms talk that I am giving on Friday at Plone Conf.
Changed:
_U z3c.talk/trunk/
A z3c.talk/trunk/Makefile
A z3c.talk/trunk/Z3CForms/
A z3c.talk/trunk/Z3CForms/Z3CForms.txt
A z3c.talk/trunk/Z3CForms/form-graph.png
A z3c.talk/trunk/Z3CForms/talk.z3cform/
A z3c.talk/trunk/Z3CForms/talk.z3cform/bootstrap.py
A z3c.talk/trunk/Z3CForms/talk.z3cform/buildout.cfg
A z3c.talk/trunk/Z3CForms/talk.z3cform/setup.py
A z3c.talk/trunk/Z3CForms/talk.z3cform/src/
A z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/
A z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/__init__.py
A z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/
A z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/README.txt
A z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/__init__.py
A z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/app.zcml
A z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/browser.py
A z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/browser.zcml
A z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/configure.zcml
A z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/display.pt
A z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/form.pt
A z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/ftesting.zcml
A z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/interfaces.py
A z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/message.py
A z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/testing.py
A z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/tests.py
A z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/view.pt
A z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/what-values.csv
A z3c.talk/trunk/Z3CForms/widget-graph.png
A z3c.talk/trunk/codeblock.py
A z3c.talk/trunk/rst2s5.py
-=-
Property changes on: z3c.talk/trunk
___________________________________________________________________
Name: svn:externals
+ s5-themes svn://svn.zope.org/repos/main/s5-themes
Added: z3c.talk/trunk/Makefile
===================================================================
--- z3c.talk/trunk/Makefile (rev 0)
+++ z3c.talk/trunk/Makefile 2008-10-08 17:18:26 UTC (rev 91909)
@@ -0,0 +1,31 @@
+TALKS="StateOfZope3-PC08 Z3CForms"
+REST2S5="./rst2s5.py"
+THEME_URL="../s5-themes/zope"
+STYLESHEET_PATH="./s5-themes/zope/reference.css"
+
+all: build
+
+build:
+ for talk in "$(TALKS)"; do \
+ echo "Generating $$talk"; \
+ $(REST2S5) --stylesheet $(STYLESHEET_PATH) \
+ --theme-url $(THEME_URL) \
+ ./$$talk/$$talk.txt \
+ ./$$talk/$$talk.html; \
+ done; \
+ echo
+
+single:
+ echo "Generating $$talk"; \
+ $(REST2S5) --stylesheet $(STYLESHEET_PATH) \
+ --theme-url $(THEME_URL) \
+ ./$$talk/$$talk.txt \
+ ./$$talk/$$talk.html; \
+
+
+clean:
+ for talk in "$(TALKS)"; do \
+ rm ./$$talk/$$talk.html; \
+ rm -rf ./$$talk/ui; \
+ done; \
+ echo
Property changes on: z3c.talk/trunk/Makefile
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: z3c.talk/trunk/Z3CForms
___________________________________________________________________
Name: svn:ignore
+ Z3cForms.html
Added: z3c.talk/trunk/Z3CForms/Z3CForms.txt
===================================================================
--- z3c.talk/trunk/Z3CForms/Z3CForms.txt (rev 0)
+++ z3c.talk/trunk/Z3CForms/Z3CForms.txt 2008-10-08 17:18:26 UTC (rev 91909)
@@ -0,0 +1,757 @@
+.. include:: <s5defs.txt>
+
+.. Creative Commons Attribution-Share Alike 2.5 License.
+.. (c) Stephan Richter
+
+========================
+ Introduction Z3C Forms
+========================
+
+:Location: Plone Conference 2008, Washington, DC
+:Date: October 10, 2008
+:Presenter: Stephan Richter, Keas Inc.
+
+.. class:: center big
+
+ Mastering the digital bureaucracy perferctly.
+
+
+Getting Started
+===============
+
+- Read the freaking manual! (409kB ~ 400 pages)
+
+- Install, run and study ``z3c.formdemo``::
+
+ $ svn co svn://svn.zope.org/repos/main/z3c.formdemo/trunk formdemo
+ $ cd formdemo
+ $ python bootstrap.py
+ $ ./bin/buildout -N
+ $ ./bin/demo fg
+
+- Ask a question if something is unclear
+
+
+Just Kidding
+============
+
+.. class:: big center
+
+ Juuuussttt kidding!
+
+
+Your Choice
+===========
+
+Today you have the choice between:
+
+1. a typical talk about ``z3c.form`` and its extensions
+
+or
+
+2. a tutorial (as promised in the brochure) building a small ``z3c.form`` app
+
+
+Form Automation
+===============
+
+* Writing forms and form handlers is a pain
+
+* Schemas/Fields usually carry enough information to generate forms
+
+* Benefits
+
+ + form framework does all the tedious bits
+
+ + automatic validation against schema
+
+ + nice error messages
+
+ + reusable form components (widgets)
+
+.. class:: handout
+
+ Form automation is an extremely viable part in making Zope 3 a
+ high-productivity environment. In fact, the implementation presented in this
+ session is already the third generation of form machinery. Older versions
+ are still available in ``zope.app.form`` and ``zope.formlib`` but is not
+ used anymore other than in legacy code.
+
+
+Forms
+=====
+
+* Presentation component
+
+* Must not be a full page (in fact, in viewlet- and pagelet-driven UIs it is
+ not)
+
+* Uses *(form) fields* and *widgets* to render a form
+
+* Defines *buttons* that generate form *actions*
+
+* Commonly a *template* is associated with a form to describe the layout
+
+.. class:: handout
+
+ If the UI requirements are consistent enough, it is sufficient to use one
+ generic template for all or most forms. In my experience, however, this has
+ not been the case and I have always ended up writing templates for each
+ form. With enough helper functions this is commonly a quick task and does
+ not represent a significant amount of the development time.
+
+
+Fields
+======
+
+* Fields represent attributes/properties in the form
+
+ See ``z3c.form.field``
+
+* Extend schema fields with form-specific information (name prefixes,
+ editability, custom widget, etc.)
+
+* (Form) fields are the traffickers between the form, schema field, and widget
+
+* An API exists to selectively choose fields of a schema to become form fields
+
+
+Creating a Schema
+=================
+
+* Schemas are just interfaces:
+
+ .. code-block:: Python
+
+ import zope.interface
+ import zope.schema
+
+ class IHelloWorldMessage(zope.interface.Interface):
+ """Information about a hello world message"""
+
+ who = zope.schema.TextLine(
+ title=u'Who',
+ description=u'Name of the person sending the message',
+ required=True)
+
+ when = zope.schema.Date(
+ title=u'When',
+ description=u'Date of the message sent.',
+ required=True)
+
+ what = zope.schema.Choice(
+ title=u'What',
+ description=u'What type of message it is.',
+ values=(u'cool', u'sunny', u'silent', u'best'),
+ required=True)
+
+
+Selecting Fields
+================
+
+* Selecting all fields of a schema:
+
+ .. code-block:: Python
+
+ fields = field.Fields(IHelloWorldMessage)
+
+* Selecting only a limited set of fields or changing the order:
+
+ .. code-block:: Python
+
+ fields = field.Fields(IHelloWorldMessage).select('when', 'who')
+
+* Omitting a particular field:
+
+ .. code-block:: Python
+
+ fields = field.Fields(IHelloWorldMessage).omit('what')
+
+* Combining fields from different schemas:
+
+ .. code-block:: Python
+
+ fields = (
+ field.Fields(IHelloWorldMessage, prefix='msg') +
+ field.Fields(IZopeDublinCore, prefix='dc', for_display=True)
+ )
+
+ .. class:: handout
+
+ I have never needed this feature. :-)
+
+
+Widgets
+=======
+
+* Represent an input method in a particular user interface, for example a
+ "text" input in HTML forms
+
+* Presentation component of a schema field (field widget)
+
+ See ``z3c.form.widget`` and ``z3c.form.browser``
+
+* Modes determine whether a display, edit or hidden widget is displayed
+
+.. class:: handout
+
+ In contrast to previous widget implementations, the ``z3c.form`` package's
+ widgets are very simple and are only respsonsible for ensuring the correct
+ rendering in the output media, in our case most often HTML forms.
+
+
+Widget-Related Components
+=========================
+
+* *Converters* are used to convert internal or field values to
+ widget-processable values
+
+ .. class:: handout
+
+ For example, if we want to edit an integer in a standard text input, then it
+ has to be converted to a string, since this is the only value type the
+ widget knows how to process. So 1200.67 might be converted to "1,200.67".
+
+* *Validators* are used to validate submitted input
+
+* Validators can raise ``ValidationError`` errors which use
+ ``ErrorViewSnippet`` presentation components to render themselves
+
+* *Data Managers* are used to store a value to a content component
+
+ .. class:: handout
+
+ In older form implementations, forms were only able to store field values
+ into instances. Providing the abstraction of a data manager, allows us to
+ store submitted data in other types of components, such as dictionaries.
+
+
+Widget Components Graph
+=======================
+
+.. image:: widget-graph.png
+ :alt: Widget Component Structure
+ :align: center
+
+
+Buttons
+=======
+
+* Defines actions of a form
+
+ See ``z3c.form.button``
+
+* Simple extension to schema fields
+
+* *Conditions* determine the availability of a button
+
+* Many ways to create buttons
+
+* A form can have multiple sets of button sets
+
+
+Actions
+=======
+
+* Actions are the widgets for buttons
+
+* In HTML rendered as submit or button input field
+
+* *Handlers* define set of instructions to execute when action is called
+ (i.e. button is pressed)
+
+ - Can be registered for specifc buttons or types of buttons
+
+ - High-level decorators are used to declare handlers
+
+
+Declaring Buttons (1)
+=====================
+
+* Buttons as schema fields:
+
+ .. code-block:: Python
+
+ class IButtons(zope.interface.Interface):
+ apply = button.Button(title=u'Apply')
+
+ class MyForm(Form):
+ buttons = button.Buttons(IButtons)
+
+* Single buttons within the form:
+
+ .. code-block:: Python
+
+ class MyForm(Form):
+ buttons = button.Buttons(
+ button.Button('apply', title=u'Apply'))
+
+Declaring Buttons (2)
+=====================
+
+* Declaring buttons via decorators:
+
+ .. code-block:: Python
+
+ @button.buttonAndHandler(u'Apply')
+ def apply(self, action):
+ ...
+
+ - First argument is title of button
+
+ - Accepts all (keyword) arguments of the button field
+
+ - ``provides`` argument allows directly providing interfaces
+
+* Copy buttons, actions and handlers from the super-form:
+
+ .. code-block:: Python
+
+ form.extends(EditForm)
+
+ .. class:: handout
+
+ It is fairly common to extend a form super-class. This is needed when the
+ sub-class wants to define/override additional buttons, actions or
+ handlers. others. If any of the three component collections are not
+ copied, the assignment will override the collections in the super-class,
+ which in turn affects all sub-classes, not just thw current one.
+
+
+Form Classes
+============
+
+* ``BaseForm`` for basic machinery
+
+* ``DisplayForm`` for standard forms to display values
+
+* ``Form`` for basic machinery including buttons
+
+* ``AddForm`` for standard add forms
+
+* ``EditForm`` for standard edit forms
+
+* ``DisplayForm`` for standard forms to display values
+
+.. class:: handout
+
+ To keep matters simple within the form package, those forms do not directly
+ proivde the correct APIs for advanced UI patterns such as viewlets and view
+ templates. However, the overhead to make them work well with those pattersn
+ is very small and a common base class is quickly developed.
+
+
+Form Components Graph
+=====================
+
+.. image:: form-graph.png
+ :alt: Form Component Structure
+ :align: center
+
+
+Hello World Content
+===================
+
+.. code-block:: Python
+
+ import persistent
+ import zope.location
+ from zope.schema.fieldproperty import FieldProperty
+ from training.z3cform import interfaces
+
+ class HelloWorldMessage(zope.location.Location, persistent.Persistent):
+ zope.interface.implements(interfaces.IHelloWorldMessage)
+
+ who = FieldProperty(interfaces.IHelloWorldMessage['who'])
+ when = FieldProperty(interfaces.IHelloWorldMessage['when'])
+ what = FieldProperty(interfaces.IHelloWorldMessage['what'])
+
+ def __init__(self, who, when, what):
+ self.who = who
+ self.when = when
+ self.what = what
+
+
+Hooking up the Content
+======================
+
+* Declarations made in ZCML:
+
+ .. code-block:: XML
+
+ <class class=".message.HelloWorldMessage">
+ <allow
+ interface=".interfaces.IHelloWorldMessage"
+ />
+ <allow
+ permission="zope.Public"
+ set_schema=".interfaces.IHelloWorldMessage"
+ />
+ </class>
+
+ .. class:: handout
+
+ These directives effectively define the setup of the checker for the
+ class. The ``zope:allow`` and ``zope:require`` directives are used to
+ define the get- and set-permissions needed for accessing each
+ attribute. If no permission is assigned to an attribute getter/setter,
+ then the attribute is unavailable to all while the component is security
+ proxied.
+
+* ZCML directives are well-documented in the API Docs at
+ http://apidoc.zope.org
+
+
+Add Forms
+=========
+
+* Create object with an initial set of data
+
+* Validate data before object is created
+
+* ``IAdding`` components not directly supported, but support exists
+
+ See ``z3c.form.adding.AddForm``
+
+ .. class:: handout
+
+ ``IAdding`` is a component designed to control the process of adding a new
+ content component to a container. It controls the object to be created and
+ the name that is given. The Adding component was originally developed for
+ CMS-like applications, but it turns out that it is a lot of overhead for
+ non-CMS sites. Thus it is advisable to avoid the adding component in
+ general.
+
+* Implementation:
+
+ .. class:: small
+
+ + Must create object from data
+
+ + Must notify the system of the object creation
+
+ + Must add the object to the container/parent component
+
+ + Must specify what to do next (specify next URL)
+
+
+Message Add Form (1)
+====================
+
+.. code-block:: Python
+
+ from zope.traversing.browser import absoluteURL
+ from z3c.form import form, field
+ from training.form import interfaces, message
+
+ class HelloWorldAddForm(form.AddForm):
+ label = u'Hello World Message Add Form'
+ fields = field.Fields(interfaces.IHelloWorldMessage)
+ template = pagetemplate.ViewPageTemplateFile('form.pt')
+
+ def create(self, data):
+ return message.HelloWorldMessage(**data)
+
+ def add(self, object):
+ count = 0
+ while 'helloworld-%i' %count in self.context:
+ count += 1;
+ self._name = 'helloworld-%i' %count
+ self.context[self._name] = object
+ return object
+
+ def nextURL(self):
+ return absoluteURL(self.context[self._name], self.request)
+
+.. class:: handout
+
+ As you can see, we only need to implement three simple methods. The
+ ``create()`` method's job is to create a valid component from the data of
+ the form and return it. Next, the ``add(object)`` method is responsible for
+ adding the object -- usually to a contained. Part of its contract is that it
+ chooses a valid name. The ``nextURL()`` method simply returns a path to
+ redirect to.
+
+Message Add Form (2)
+====================
+
+* Register form as a simple page of ``IFolder``:
+
+ .. code-block:: XML
+
+ <page
+ name="addHelloWorld.html"
+ for="zope.app.folder.interfaces.IFolder"
+ class=".browser.HelloWorldAddForm"
+ layer=".browser.IFormSkin"
+ permission="zope.Public"
+ />
+
+ .. class:: small
+
+ Note: We must create a custom skin so that registrations are included.
+
+ .. code-block:: Python
+
+ from z3c.form.interfaces import IFormLayer
+ from z3c.formui.interfaces import IDivFormLayer
+
+ class IFormSkin(IDivFormLayer, IFormLayer, rotterdam.Rotterdam):
+ """Form Skin"""
+
+* After restarting Zope 3, the add form should be available
+
+* There is no link in the ZMI, because no menu was registered
+
+ .. class:: handout
+
+ Since we skipped the overhead of ``IAdding``, adding a menu item is hard,
+ unfortunately. Note, however, that you will almost never use the ZMI to
+ add objects, so filling the ZMI add menu is pretty pointless anyways.
+
+
+Message Add Form (3)
+====================
+
+.. code-block:: XML
+
+ <html>
+ <head>
+ <link type="text/css" rel="stylesheet"
+ href="somestyle.css" media="all"
+ tal:attributes="href context/++resource++div-form.css" />
+ </head>
+ <body>
+ <div metal:use-macro="macro:form">
+ Form goes here.
+ </div>
+ </body>
+ </html>
+
+.. class:: handout
+
+ ``z3c.form`` was written with pagelets in mind. Since we want to keep the
+ example as self-contained as possible, we are not using pagelets, which
+ means that we have to define our own form templates. The ``div-form.css``
+ CSS resource and the ``form`` macro are registered in the ``IDivFormLayer``
+ layer.
+
+
+Custom Widget Value
+===================
+
+* Framework allows us to create custom attribute values for several widget
+ attributes
+
+* Make today's date the default for the ``when`` field
+
+ .. code-block:: Python
+
+ import datetime
+ from z3c.form import widget
+ from z3c.form.interfaces import IAddForm
+ from training.z3cform import interfaces
+
+ DefaultDate = widget.ComputedWidgetAttribute(
+ lambda adapter: datetime.date.today(),
+ field=interfaces.IHelloWorldMessage['when'], view=IAddForm)
+
+* A simple adapter to register
+
+ .. code-block:: XML
+
+ <adapter
+ factory=".browser.DefaultDate"
+ name="default" />
+
+ .. class:: handout
+
+ Note that the name of the adapter must be the name of the attribute that
+ we are providing the value for.
+
+
+Display Forms
+=============
+
+* Bad idea to display data right out of the content object
+
+* Some data requires formatting, such as dates and vocabulary values
+
+* Display forms produce human-readable representations of data
+
+* Display widgets are used
+
+.. class:: handout
+
+ While writing display forms every time you want to present a value might
+ seem tedious at first, but it is worth the discipline. Otherwise you will
+ eventually have unwanted presentation bugs. Common base classes can easily
+ be created to make this a very trivial part of the development.
+
+
+Message Display (1)
+===================
+
+* The Python view class:
+
+ .. code-block:: Python
+
+ class HelloWorldDisplayForm(form.DisplayForm):
+ fields = field.Fields(interfaces.IHelloWorldMessage)
+ template = pagetemplate.ViewPageTemplateFile('display.pt')
+
+ def __call__(self):
+ self.update()
+ return self.render()
+
+
+Message Display (2)
+===================
+
+* The page template using the widgets:
+
+ .. code-block:: XML
+
+ <html>
+ <body>
+ <h1>
+ A <span tal:replace="structure view/widgets/what/render" />
+ Hello World
+ from <span tal:replace="structure view/widgets/who/render" />
+ on <span tal:replace="structure view/widgets/when/render" />!
+ </h1>
+ <a href="./edit.html"
+ tal:attributes="href
+ string:${context/@@absolute_url}/edit.html"
+ >Edit Message</a>
+ </body>
+ </html>
+
+
+Message Display (3)
+===================
+
+* Registering the display view:
+
+ .. code-block:: XML
+
+ <page
+ name="index.html"
+ for=".interfaces.IHelloWorldMessage"
+ class=".browser.HelloWorldDisplayForm"
+ layer=".browser.IFormSkin"
+ permission="zope.Public"
+ />
+
+* To add an entry to the tabs, add the following to the page directive:
+
+ .. code-block:: XML
+
+ menu="zmi_views" title="View"
+
+
+Edit Forms
+==========
+
+* Change existing objects
+
+* Can stack multiple forms into one page
+
+* Switching between edit and view mode relatively simple
+
+.. class:: handout
+
+ Edit forms are great, because their scope is limited and they can be easily
+ used within other presentation components, allowing you to implement many
+ interesting patterns.
+
+
+Hello World Edit Form (1)
+=========================
+
+* An edit form with an additional custom button that switches back to the
+ display view after saving the changes.
+
+ .. code-block:: Python
+
+ from z3c.form import button
+
+ class HelloWorldEditForm(form.EditForm):
+ form.extends(form.EditForm)
+ label = u'Hello World Message Edit Form'
+ fields = field.Fields(interfaces.IHelloWorldMessage)
+
+ @button.buttonAndHandler(u'Apply and View', name='applyView')
+ def handleApplyView(self, action):
+ self.handleApply(self, action)
+ if not self.widgets.errors:
+ url = absoluteURL(self.context, self.request)
+ self.request.response.redirect(url)
+
+.. class:: handout
+
+ In this case we are using an existing action and just extend it. The
+ existing "Apply" action saves the data, but also remains in the edit
+ view. Our new action, "Apply and View", saves the data, but forwards the
+ user to the view page.
+
+
+Hello World Edit Form (2)
+=========================
+
+* Register form as a simple page of ``IHelloWorldMessage``:
+
+ .. code-block:: XML
+
+ <page
+ name="edit.html"
+ for=".interfaces.IHelloWorldMessage"
+ class=".browser.HelloWorldEditForm"
+ layer=".browser.IFormSkin"
+ permission="zope.Public"
+ />
+
+* After restarting Zope 3, the edit form should be available
+
+* Add to tabs, add the following to the page directive:
+
+ .. code-block:: XML
+
+ menu="zmi_views" title="Edit"
+
+
+The Future -- ``z3c.form`` 2.0
+==============================
+
+- Integration of ``z3c.pt``
+
+ * Benchmarks show that form generation is 2-3 times faster
+
+- New widgets:
+
+ * ``TextLinesWidget`` widget to edit a sequence of simple values in a text area
+
+ * ``MultiWidget`` wisget to manage a sequence of simple types
+
+ * ``ObjectWidget`` widget provides a simple way to edit ``Object`` fields
+
+- Translations
+
+
+Extensions to ``z3c.form``
+==========================
+
+- ``z3c.formjs`` -- Javascript and Ajax
+
+ * See ``z3c.formjsdemo``
+
+- ``z3c.formwidget.query`` -- A widget to query a large collection and select
+ a value from the query results
+
+- ``plone.z3cform`` -- Integration of ``z3c.form`` into CMF and Plone
+
+- ``megrok.z3cform`` -- Integration of ``z3c.form`` into Grok
+
+- ``five.megrok.z3cform`` -- Five bridge of ``megrok.z3cform``
+
+- ``z3c.formext`` -- Soon to come from Keas
Property changes on: z3c.talk/trunk/Z3CForms/Z3CForms.txt
___________________________________________________________________
Name: svn:eol-style
+ native
Added: z3c.talk/trunk/Z3CForms/form-graph.png
===================================================================
(Binary files differ)
Property changes on: z3c.talk/trunk/Z3CForms/form-graph.png
___________________________________________________________________
Name: svn:mime-type
+ image/png
Added: z3c.talk/trunk/Z3CForms/talk.z3cform/bootstrap.py
===================================================================
--- z3c.talk/trunk/Z3CForms/talk.z3cform/bootstrap.py (rev 0)
+++ z3c.talk/trunk/Z3CForms/talk.z3cform/bootstrap.py 2008-10-08 17:18:26 UTC (rev 91909)
@@ -0,0 +1,52 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""Bootstrap a buildout-based project
+
+Simply run this script in a directory containing a buildout.cfg.
+The script accepts buildout command-line options, so you can
+use the -c option to specify an alternate configuration file.
+
+$Id$
+"""
+
+import os, shutil, sys, tempfile, urllib2
+
+tmpeggs = tempfile.mkdtemp()
+
+ez = {}
+exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
+ ).read() in ez
+ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
+
+import pkg_resources
+
+cmd = 'from setuptools.command.easy_install import main; main()'
+if sys.platform == 'win32':
+ cmd = '"%s"' % cmd # work around spawn lamosity on windows
+
+ws = pkg_resources.working_set
+assert os.spawnle(
+ os.P_WAIT, sys.executable, sys.executable,
+ '-c', cmd, '-mqNxd', tmpeggs, 'zc.buildout',
+ dict(os.environ,
+ PYTHONPATH=
+ ws.find(pkg_resources.Requirement.parse('setuptools')).location
+ ),
+ ) == 0
+
+ws.add_entry(tmpeggs)
+ws.require('zc.buildout')
+import zc.buildout.buildout
+zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap'])
+shutil.rmtree(tmpeggs)
Property changes on: z3c.talk/trunk/Z3CForms/talk.z3cform/bootstrap.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: z3c.talk/trunk/Z3CForms/talk.z3cform/buildout.cfg
===================================================================
--- z3c.talk/trunk/Z3CForms/talk.z3cform/buildout.cfg (rev 0)
+++ z3c.talk/trunk/Z3CForms/talk.z3cform/buildout.cfg 2008-10-08 17:18:26 UTC (rev 91909)
@@ -0,0 +1,24 @@
+[buildout]
+develop = .
+parts = zope test
+index = http://download.zope.org/zope3.4/
+
+[zope3]
+location = .
+
+[z3cform-app]
+recipe = zc.zope3recipes:app
+site.zcml = <include package="talk.z3cform" file="app.zcml" />
+eggs = talk.z3cform [app]
+
+[zope]
+recipe = zc.zope3recipes:instance
+application = z3cform-app
+zope.conf = ${database:zconfig}
+
+[database]
+recipe = zc.recipe.filestorage
+
+[test]
+recipe = zc.recipe.testrunner
+eggs = talk.z3cform [app, test]
Added: z3c.talk/trunk/Z3CForms/talk.z3cform/setup.py
===================================================================
--- z3c.talk/trunk/Z3CForms/talk.z3cform/setup.py (rev 0)
+++ z3c.talk/trunk/Z3CForms/talk.z3cform/setup.py 2008-10-08 17:18:26 UTC (rev 91909)
@@ -0,0 +1,64 @@
+from setuptools import setup, find_packages
+
+setup(
+ name='talk.z3cform',
+ version='0.1.0dev',
+ author='Trainee',
+ author_email='zope-dev at zope.org',
+ description='Zope 3 Talk: Z3C Forms',
+ long_description='Zope 3 Talk: Z3C Forms',
+ license='ZPL 2.1',
+ keywords='zope3 talk z3cform',
+ classifiers=[
+ 'Development Status :: 3 - Alpha',
+ 'Environment :: Web Environment',
+ 'License :: OSI Approved :: Zope Public License',
+ 'Programming Language :: Python',
+ 'Natural Language :: English',
+ 'Operating System :: OS Independent',
+ 'Topic :: Internet :: WWW/HTTP',
+ 'Framework :: Zope3'],
+ url='http://pypi.python.org/pypi/talk.z3cform',
+ packages = find_packages('src'),
+ include_package_data = True,
+ package_dir = {'':'src'},
+ namespace_packages = ['talk'],
+ extras_require = dict(
+ app = [
+ 'ZODB3',
+ 'ZConfig',
+ 'zdaemon',
+ 'zope.publisher',
+ 'zope.traversing',
+ 'zope.app.wsgi',
+ 'zope.app.appsetup',
+ 'zope.app.zcmlfiles',
+ 'zope.app.securitypolicy',
+ 'zope.app.twisted',
+ # APIDOC packages
+ 'zope.app.apidoc',
+ 'zope.app.preference',
+ 'zope.app.onlinehelp',
+ # The following packages aren't needed from the
+ # beginning, but end up being used in most apps
+ 'zope.annotation',
+ 'zope.copypastemove',
+ 'zope.i18n',
+ 'zope.app.authentication',
+ 'zope.app.session',
+ 'zope.app.intid',
+ 'zope.app.keyreference',
+ 'zope.app.catalog',
+ ],
+ test = [
+ 'zope.testbrowser',
+ 'zope.app.testing'],
+ ),
+ install_requires = [
+ 'setuptools',
+ 'z3c.csvvocabulary',
+ 'z3c.form',
+ 'z3c.formui',
+ ],
+ zip_safe = False,
+ )
Property changes on: z3c.talk/trunk/Z3CForms/talk.z3cform/setup.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/__init__.py
===================================================================
--- z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/__init__.py (rev 0)
+++ z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/__init__.py 2008-10-08 17:18:26 UTC (rev 91909)
@@ -0,0 +1,8 @@
+try:
+ # Declare this a namespace package if pkg_resources is available.
+ import pkg_resources
+ pkg_resources.declare_namespace(__name__)
+except ImportError:
+ pass
+
+
Property changes on: z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/README.txt
===================================================================
--- z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/README.txt (rev 0)
+++ z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/README.txt 2008-10-08 17:18:26 UTC (rev 91909)
@@ -0,0 +1,81 @@
+=======================
+The Hello World Message
+=======================
+
+This package implements the forms for the Hello World Message content
+component.
+
+Create a browser instance:
+
+ >>> from zope.testbrowser.testing import Browser
+ >>> manager = Browser()
+ >>> manager.addHeader('Authorization', 'Basic mgr:mgrpw')
+ >>> manager.addHeader('Accept-Language', 'en')
+
+Let's create a message component first:
+
+ >>> manager.handleErrors = False
+ >>> manager.open('http://localhost:8080/++skin++Form/addHelloWorld.html')
+
+ >>> manager.getControl('Who').value = u'Stephan'
+ >>> manager.getControl('When').value = u'1/1/07'
+ >>> manager.getControl('What').getControl('sunny').click()
+
+ >>> manager.getControl('Add').click()
+
+We should be forwarded to the message's display screen:
+
+ >>> print manager.contents
+ <html...
+ <h1>
+ A <span id="form-widgets-what"
+ class="select-widget required choice-field">
+ <span class="selected-option">sunny</span>
+ </span>
+ Hello World
+ from <span id="form-widgets-who"
+ class="text-widget required textline-field">
+ Stephan
+ </span>
+ <BLANKLINE>
+ on <span id="form-widgets-when"
+ class="text-widget required date-field">
+ 1/1/07
+ </span>
+ !
+ </h1>
+ ...
+
+
+You can click the edit button to change the data:
+
+ >>> manager.getLink('Edit Message').click()
+
+ >>> manager.getControl('Who').value = u'Roger'
+ >>> manager.getControl('When').value = u'1/2/07'
+ >>> manager.getControl('What').getControl('best').click()
+
+ >>> manager.getControl('Apply and View').click()
+
+This action forwards you again to the view page:
+
+ >>> print manager.contents
+ <html...
+ <h1>
+ A <span id="form-widgets-what"
+ class="select-widget required choice-field">
+ <span class="selected-option">best</span>
+ </span>
+ Hello World
+ from <span id="form-widgets-who"
+ class="text-widget required textline-field">
+ Roger
+ </span>
+ <BLANKLINE>
+ on <span id="form-widgets-when"
+ class="text-widget required date-field">
+ 1/2/07
+ </span>
+ !
+ </h1>
+ ...
Property changes on: z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/README.txt
___________________________________________________________________
Name: svn:eol-style
+ native
Added: z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/__init__.py
===================================================================
--- z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/__init__.py (rev 0)
+++ z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/__init__.py 2008-10-08 17:18:26 UTC (rev 91909)
@@ -0,0 +1 @@
+# Make this directory a package
Property changes on: z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/app.zcml
===================================================================
--- z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/app.zcml (rev 0)
+++ z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/app.zcml 2008-10-08 17:18:26 UTC (rev 91909)
@@ -0,0 +1,86 @@
+<configure xmlns="http://namespaces.zope.org/zope"
+ i18n_domain="getstarted">
+
+ <include package="zope.security" file="meta.zcml" />
+ <include package="zope.app.zcmlfiles" file="meta.zcml" />
+
+ <include package="zope.publisher" />
+ <include package="zope.traversing" />
+ <include package="zope.traversing.browser" />
+ <include package="zope.app.zcmlfiles" />
+ <include package="zope.app.twisted" />
+
+ <!-- APIDOC packages -->
+ <include package="zope.app.preference" file="meta.zcml" />
+ <include package="zope.app.apidoc" file="meta.zcml" />
+ <include package="zope.app.onlinehelp" file="meta.zcml" />
+
+ <include package="zope.app.zcmlfiles" />
+ <include package="zope.app.tree" />
+ <include package="zope.app.onlinehelp" />
+ <include package="zope.app.renderer" />
+ <include package="zope.app.preference" />
+ <include package="zope.app.apidoc" />
+
+ <!-- The following packages aren't needed from the beginning, but
+ end up being used in most applications -->
+ <include package="zope.viewlet" file="meta.zcml" />
+ <include package="zope.i18n" file="meta.zcml" />
+ <include package="z3c.form" file="meta.zcml" />
+ <include package="z3c.macro" file="meta.zcml" />
+ <include package="z3c.template" file="meta.zcml" />
+ <include package="z3c.form" />
+ <include package="z3c.formui" />
+ <include package="z3c.macro" />
+ <include package="zope.annotation" />
+ <include package="zope.copypastemove" />
+ <include package="zope.formlib" />
+ <include package="zope.i18n.locales" />
+ <include package="zope.app.authentication" />
+ <include package="zope.app.session" />
+ <include package="zope.app.intid" />
+ <include package="zope.app.keyreference" />
+ <include package="zope.app.catalog" />
+
+ <include package="zope.app.securitypolicy" file="meta.zcml" />
+ <include package="zope.app.securitypolicy" />
+ <securityPolicy
+ component="zope.securitypolicy.zopepolicy.ZopeSecurityPolicy" />
+
+ <include package="talk.z3cform" />
+
+
+ <unauthenticatedPrincipal
+ id="zope.anybody"
+ title="Unauthenticated User" />
+ <unauthenticatedGroup
+ id="zope.Anybody"
+ title="Unauthenticated Users" />
+ <authenticatedGroup
+ id="zope.Authenticated"
+ title="Authenticated Users" />
+ <everybodyGroup
+ id="zope.Everybody"
+ title="All Users" />
+
+ <!-- Initial administrator account. Disable this for production -->
+ <principal id="zope.manager"
+ title="Manager"
+ login="admin"
+ password_manager="Plain Text"
+ password="admin"
+ />
+
+ <!-- Replace the following directive if you don't want public access -->
+ <grant permission="zope.View"
+ principal="zope.Anybody" />
+ <grant permission="zope.app.dublincore.view"
+ principal="zope.Anybody" />
+
+ <role id="zope.Manager" title="Site Manager" />
+ <role id="zope.Member" title="Site Member" />
+ <grantAll role="zope.Manager" />
+ <grant role="zope.Manager"
+ principal="zope.manager" />
+
+</configure>
Property changes on: z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/app.zcml
___________________________________________________________________
Name: svn:eol-style
+ native
Added: z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/browser.py
===================================================================
--- z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/browser.py (rev 0)
+++ z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/browser.py 2008-10-08 17:18:26 UTC (rev 91909)
@@ -0,0 +1,59 @@
+import datetime
+from zope.app import pagetemplate
+from zope.app import rotterdam
+from zope.traversing.browser import absoluteURL
+from z3c.form import button, field, form, widget
+from z3c.form.interfaces import IAddForm, IFormLayer
+from z3c.formui.interfaces import IDivFormLayer
+
+from talk.z3cform import interfaces, message
+
+
+class IFormSkin(IDivFormLayer, IFormLayer, rotterdam.Rotterdam):
+ """Form Skin"""
+
+DefaultDate = widget.ComputedWidgetAttribute(
+ lambda adapter: datetime.date.today(),
+ field=interfaces.IHelloWorldMessage['when'], view=IAddForm)
+
+class HelloWorldAddForm(form.AddForm):
+ label = u'Hello World Message Add Form'
+ fields = field.Fields(interfaces.IHelloWorldMessage)
+ template = pagetemplate.ViewPageTemplateFile('form.pt')
+
+ def create(self, data):
+ return message.HelloWorldMessage(**data)
+
+ def add(self, object):
+ count = 0
+ while 'helloworld-%i' %count in self.context:
+ count += 1;
+ self._name = 'helloworld-%i' %count
+ self.context[self._name] = object
+ return object
+
+ def nextURL(self):
+ return absoluteURL(self.context[self._name], self.request)
+
+
+class HelloWorldEditForm(form.EditForm):
+ form.extends(form.EditForm)
+ label = u'Hello World Message Edit Form'
+ fields = field.Fields(interfaces.IHelloWorldMessage)
+ template = pagetemplate.ViewPageTemplateFile('form.pt')
+
+ @button.buttonAndHandler(u'Apply and View', name='applyView')
+ def handleApplyView(self, action):
+ self.handleApply(self, action)
+ if not self.widgets.errors:
+ url = absoluteURL(self.context, self.request)
+ self.request.response.redirect(url)
+
+
+class HelloWorldDisplayForm(form.DisplayForm):
+ fields = field.Fields(interfaces.IHelloWorldMessage)
+ template = pagetemplate.ViewPageTemplateFile('display.pt')
+
+ def __call__(self):
+ self.update()
+ return self.render()
Property changes on: z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/browser.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/browser.zcml
===================================================================
--- z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/browser.zcml (rev 0)
+++ z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/browser.zcml 2008-10-08 17:18:26 UTC (rev 91909)
@@ -0,0 +1,35 @@
+<configure
+ xmlns="http://namespaces.zope.org/browser"
+ xmlns:zope="http://namespaces.zope.org/zope">
+
+ <zope:interface
+ interface=".browser.IFormSkin"
+ type="zope.publisher.interfaces.browser.IBrowserSkinType"
+ name="Form"
+ />
+
+ <page
+ name="index.html"
+ for=".interfaces.IHelloWorldMessage"
+ class=".browser.HelloWorldDisplayForm"
+ layer=".browser.IFormSkin"
+ permission="zope.Public"
+ />
+
+ <page
+ name="edit.html"
+ for=".interfaces.IHelloWorldMessage"
+ class=".browser.HelloWorldEditForm"
+ layer=".browser.IFormSkin"
+ permission="zope.Public"
+ />
+
+ <page
+ name="addHelloWorld.html"
+ for="zope.app.folder.interfaces.IFolder"
+ class=".browser.HelloWorldAddForm"
+ layer=".browser.IFormSkin"
+ permission="zope.Public"
+ />
+
+</configure>
Property changes on: z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/browser.zcml
___________________________________________________________________
Name: svn:eol-style
+ native
Added: z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/configure.zcml
===================================================================
--- z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/configure.zcml (rev 0)
+++ z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/configure.zcml 2008-10-08 17:18:26 UTC (rev 91909)
@@ -0,0 +1,28 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:z3c="http://namespaces.zope.org/z3c"
+ i18n_domain="z3c.formdemo">
+
+ <permission
+ id="talk.z3cform.ManageHelloWorld"
+ title="Manage Hello World (z3c.formdemo)"
+ />
+
+ <class class=".message.HelloWorldMessage">
+ <allow
+ interface=".interfaces.IHelloWorldMessage"
+ />
+ <require
+ permission="talk.z3cform.ManageHelloWorld"
+ set_schema=".interfaces.IHelloWorldMessage"
+ />
+ </class>
+
+ <!-- Default widget value for "when" -->
+ <adapter
+ factory=".browser.DefaultDate"
+ name="default" />
+
+ <include file="browser.zcml" />
+
+</configure>
Property changes on: z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/configure.zcml
___________________________________________________________________
Name: svn:eol-style
+ native
Added: z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/display.pt
===================================================================
--- z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/display.pt (rev 0)
+++ z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/display.pt 2008-10-08 17:18:26 UTC (rev 91909)
@@ -0,0 +1,12 @@
+<html>
+ <body>
+ <h1>
+ A <span tal:replace="structure view/widgets/what/render" /> Hello World
+ from <span tal:replace="structure view/widgets/who/render" />
+ on <span tal:replace="structure view/widgets/when/render" />!
+ </h1>
+ <a href="./edit.html"
+ tal:attributes="href string:${context/@@absolute_url}/edit.html">
+ Edit Message</a>
+ </body>
+</html>
Property changes on: z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/display.pt
___________________________________________________________________
Name: svn:eol-style
+ native
Added: z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/form.pt
===================================================================
--- z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/form.pt (rev 0)
+++ z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/form.pt 2008-10-08 17:18:26 UTC (rev 91909)
@@ -0,0 +1,11 @@
+<html>
+ <head>
+ <link type="text/css" rel="stylesheet" href="somestyle.css" media="all"
+ tal:attributes="href context/++resource++div-form.css" />
+ </head>
+ <body>
+ <div metal:use-macro="macro:form">
+ Form goes here.
+ </div>
+ </body>
+</html>
Property changes on: z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/form.pt
___________________________________________________________________
Name: svn:eol-style
+ native
Added: z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/ftesting.zcml
===================================================================
--- z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/ftesting.zcml (rev 0)
+++ z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/ftesting.zcml 2008-10-08 17:18:26 UTC (rev 91909)
@@ -0,0 +1,29 @@
+<configure xmlns="http://namespaces.zope.org/zope"
+ xmlns:meta="http://namespaces.zope.org/meta"
+ i18n_domain="talk">
+
+ <!-- Turn on the devmode -->
+ <meta:provides feature="devmode" />
+ <include file="app.zcml" />
+
+ <include package="zope.app.securitypolicy.browser.tests"
+ file="functional.zcml" />
+
+ <!-- Principal that tests generally run as -->
+ <principal
+ id="zope.mgr"
+ title="Manager"
+ login="mgr"
+ password="mgrpw"
+ />
+ <!-- Bootstrap principal used to make local grant to the principal above -->
+ <principal
+ id="zope.globalmgr"
+ title="Manager"
+ login="globalmgr"
+ password="globalmgrpw"
+ />
+
+ <grant role="zope.Manager" principal="zope.globalmgr" />
+
+</configure>
Property changes on: z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/ftesting.zcml
___________________________________________________________________
Name: svn:eol-style
+ native
Added: z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/interfaces.py
===================================================================
--- z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/interfaces.py (rev 0)
+++ z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/interfaces.py 2008-10-08 17:18:26 UTC (rev 91909)
@@ -0,0 +1,27 @@
+import os
+import zope.interface
+import zope.schema
+from z3c.csvvocabulary import CSVVocabulary
+
+WhatVocabulary = CSVVocabulary(
+ os.path.join(os.path.dirname(__file__), 'what-values.csv'))
+
+class IHelloWorldMessage(zope.interface.Interface):
+ """Information about a hello world message"""
+
+ who = zope.schema.TextLine(
+ title=u'Who',
+ description=u'Name of the person sending the message',
+ required=True)
+
+ when = zope.schema.Date(
+ title=u'When',
+ description=u'Date of the message sent.',
+ required=True)
+
+ what = zope.schema.Choice(
+ title=u'What',
+ description=u'What type of message it is.',
+ vocabulary=WhatVocabulary,
+ default=u'cool',
+ required=True)
Property changes on: z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/interfaces.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/message.py
===================================================================
--- z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/message.py (rev 0)
+++ z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/message.py 2008-10-08 17:18:26 UTC (rev 91909)
@@ -0,0 +1,17 @@
+import persistent
+import zope.interface
+from zope.location import location
+from zope.schema import fieldproperty
+from talk.z3cform import interfaces
+
+class HelloWorldMessage(location.Location, persistent.Persistent):
+ zope.interface.implements(interfaces.IHelloWorldMessage)
+
+ who = fieldproperty.FieldProperty(interfaces.IHelloWorldMessage['who'])
+ when = fieldproperty.FieldProperty(interfaces.IHelloWorldMessage['when'])
+ what = fieldproperty.FieldProperty(interfaces.IHelloWorldMessage['what'])
+
+ def __init__(self, who, when, what):
+ self.who = who
+ self.when = when
+ self.what = what
Property changes on: z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/message.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/testing.py
===================================================================
--- z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/testing.py (rev 0)
+++ z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/testing.py 2008-10-08 17:18:26 UTC (rev 91909)
@@ -0,0 +1,6 @@
+import os
+from zope.app.testing.functional import ZCMLLayer
+
+Z3CFormLayer = ZCMLLayer(
+ os.path.join(os.path.split(__file__)[0], 'ftesting.zcml'),
+ __name__, 'Z3CFormLayer', allow_teardown=True)
Property changes on: z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/testing.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/tests.py
===================================================================
--- z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/tests.py (rev 0)
+++ z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/tests.py 2008-10-08 17:18:26 UTC (rev 91909)
@@ -0,0 +1,11 @@
+import unittest
+from zope.app.testing import functional
+from talk.z3cform import testing
+
+def test_suite():
+ suite = functional.FunctionalDocFileSuite('README.txt')
+ suite.layer = testing.Z3CFormLayer
+ return unittest.TestSuite((suite,))
+
+if __name__ == '__main__':
+ unittest.main(defaultTest='test_suite')
Property changes on: z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/tests.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/view.pt
===================================================================
--- z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/view.pt (rev 0)
+++ z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/view.pt 2008-10-08 17:18:26 UTC (rev 91909)
@@ -0,0 +1,12 @@
+<html>
+ <body>
+ <h1>
+ A <span tal:replace="structure view/widgets/what" /> Hello World
+ from <span tal:replace="structure view/widgets/who" />
+ on <span tal:replace="structure view/widgets/when" />!
+ </h1>
+ <a href="./edit.html"
+ tal:attributes="href string:${context/@@absolute_url}/edit.html">
+ Edit Message</a>
+ </body>
+</html>
Property changes on: z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/view.pt
___________________________________________________________________
Name: svn:eol-style
+ native
Added: z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/what-values.csv
===================================================================
--- z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/what-values.csv (rev 0)
+++ z3c.talk/trunk/Z3CForms/talk.z3cform/src/talk/z3cform/what-values.csv 2008-10-08 17:18:26 UTC (rev 91909)
@@ -0,0 +1,4 @@
+"cool";"cool"
+"sunny";"sunny"
+"silent";"silent"
+"best";"best"
Added: z3c.talk/trunk/Z3CForms/widget-graph.png
===================================================================
(Binary files differ)
Property changes on: z3c.talk/trunk/Z3CForms/widget-graph.png
___________________________________________________________________
Name: svn:mime-type
+ image/png
Added: z3c.talk/trunk/codeblock.py
===================================================================
--- z3c.talk/trunk/codeblock.py (rev 0)
+++ z3c.talk/trunk/codeblock.py 2008-10-08 17:18:26 UTC (rev 91909)
@@ -0,0 +1,51 @@
+#!/usr/bin/env python
+
+import SilverCity
+import docutils.parsers.rst
+import StringIO
+
+def code_block( name, arguments, options, content, lineno,
+ content_offset, block_text, state, state_machine ):
+ """
+ The code-block directive provides syntax highlighting for blocks
+ of code. It is used with the the following syntax::
+
+ .. code-block:: CPP
+
+ #include <iostream>
+
+ int main( int argc, char* argv[] )
+ {
+ std::cout << "Hello world" << std::endl;
+ }
+
+ The directive requires the name of a language supported by SilverCity
+ as its only argument. All code in the indented block following
+ the directive will be colourized. Note that this directive is only
+ supported for HTML writers.
+ """
+ language = arguments[0]
+ try:
+ module = getattr(SilverCity, language)
+ generator = getattr(module, language+"HTMLGenerator")
+ except AttributeError:
+ error = state_machine.reporter.error( "No SilverCity lexer found "
+ "for language '%s'." % language,
+ docutils.nodes.literal_block(block_text, block_text), line=lineno )
+ return [error]
+ io = StringIO.StringIO()
+ generator().generate_html( io, '\n'.join(content) )
+ html = '<div class="code-block">\n%s\n</div>\n' % io.getvalue()
+ raw = docutils.nodes.raw('',html, format = 'html')
+ return [raw]
+
+code_block.arguments = (1,0,0)
+code_block.options = {'language' : docutils.parsers.rst.directives.unchanged }
+code_block.content = 1
+
+# Simply importing this module will make the directive available.
+docutils.parsers.rst.directives.register_directive( 'code-block', code_block )
+
+if __name__ == "__main__":
+ import docutils.core
+ docutils.core.publish_cmdline(writer_name='html')
Property changes on: z3c.talk/trunk/codeblock.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: z3c.talk/trunk/rst2s5.py
===================================================================
--- z3c.talk/trunk/rst2s5.py (rev 0)
+++ z3c.talk/trunk/rst2s5.py 2008-10-08 17:18:26 UTC (rev 91909)
@@ -0,0 +1,30 @@
+#!/usr/bin/python
+
+# Author: Chris Liechti
+# Contact: cliechti at gmx.net
+# Revision: $Revision: 4156 $
+# Date: $Date: 2005-12-08 05:43:13 +0100 (Thu, 08 Dec 2005) $
+# Copyright: This module has been placed in the public domain.
+
+"""
+A minimal front end to the Docutils Publisher, producing HTML slides using
+the S5 template system.
+"""
+
+try:
+ import locale
+ locale.setlocale(locale.LC_ALL, '')
+except:
+ pass
+
+import codeblock
+from docutils.core import publish_cmdline, default_description
+
+
+description = ('Generates S5 (X)HTML slideshow documents from standalone '
+ 'reStructuredText sources. ' + default_description)
+
+publish_cmdline(writer_name='s5', description=description)
+
+
+
Property changes on: z3c.talk/trunk/rst2s5.py
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Id
More information about the Checkins
mailing list