Nevow Examples

# Welcome to Nevow

This page contains examples of how to build web applications on top of Nevow, in order of increasing complexity. To get a feel of how to structure your Python code while using Nevow, the source of all examples is linked for easy reference. In order to run each example, you will need Zope Interface, Twisted, and Nevow installed, and then you will need to run the example server.

Under windows: you need to run the Twisted Shell from Start-->Applications-->Twisted menu. Under a unix like operating system, make sure that the twistd binary is on your PATH. Installing Twisted will do this for you.

To run the example server, go to the Nevow examples directory (eg: C:\Nevow\examples or /usr/src/Nevow/examples) and run the following command:

> twistd -noy examples.tac

Then, to view the running examples, point your web browser at: http://localhost:8080/

Once you are viewing this page as served by the example server, all of the "live" links below will work.

## Table of Contents

1. Test Suite
2. Examples
3. Tag Library Examples
4. Demo Applications

# Examples Listing

1. A Nevow example that doesn't use any of Nevow automations

   Stan Source | most_basic.py

   Live examples: most_basic
2. Hello world in Nevow

   Stan Source | hellostan.py
   xmlfile Source | hellohtml.py
   xmlfile Template | hellohtml.html

   Live examples: xmlfile, Stan
3. How to get Session and Request objects from the context

   Stan Source | simple.py
   xmlfile Source | simplehtml.py
   xmlfile Template | simplehtml.html

   Live examples: xmlfile, Stan
4. Render tables in Nevow

   xmlfile Source | tablehtml.py
   xmlfile Template | tablehtml.html

   Live example: tables
5. How to use xmlfile directives

   Stan Source | disktemplates_stan.py
   xmlfile Source | disktemplates.py
   xmlfile Template | disktemplates.html

   Live examples: xmlfile, Stan
6. How to handles page children with Nevow, and how to use the <nevow:attr> tag

   Stan Source | children.py
   xmlfile Source | childrenhtml.py
   xmlfile Templates | childrenhtml_RootPage.html childrenhtml_ChildPage.html childrenhtml_ChildOfChildPage.html

   Live examples: stan, xmlfile
7. Use Fragments to divide a page in logical components

   Stan Source | fragments.py
   xmlfile Template | main.html

   Live example: fragments
8. Use Macro directive to compose pages by transforming the docFactory at precompile time

   Stan Source | macros.py
   xmlfile Template | main.html root_macro.html child_macro.html

   Live example: macros
9. Allow data= directives to look inside application objects

   Stan Source | objcontainer.py

   Live example: objcontainer
10. Use nested sequences to render an attribute of type list of an object

    Stan Source | nestedsequence.py

    Live example: nestedsequence
11. Manual form example

    Stan Source | manualform.py

    Live example: form
12. Advanced manual form example

    Stan Source | advanced_manualform.py

    Live example: form
13. Formless example

    Stan Source | formpost.py

    Live example: formpost
14. Another formless example, but a little bit more complex

    Stan Source | formpost2.py

    Live example: formpost2
15. [0.5]Using formless to create multi-step wizards by returning Page instances from autocallables

    Stan Source | tests/testformless.py

    Live example: testformless
16. [0.5]Using formless, return a URL instance from an autocallable to redirect to it

    Stan Source | tests/testformless.py

    Live example: formless_redirector
17. Example of interacting with a database

    Stan Source: | db.py

    Live examples: db
18. An example of using HTTP Basic Auth for simple authentication

    Stan Source | http_auth.py

    Live example: http_auth
19. Various examples of how to integrate twisted.guard with Nevow for authentication

    Stan Source | guarded.py
    Stan Source | guarded2.py

    Live examples: guarded, guarded2
20. Examples of how to access the session when a user logs out of guarded sites

    Stan Source | logout_guard.py
    Stan Source | logout_guard2.py

    Live examples: logout_guard, logout_guard2
21. Use Configurables to render a form with Formless in a customized template

    xmlfile Source | customform.py

    Live example: customform
22. Dynamically build your forms

    Stan Source | formbuilder.py

    Live example: formbuilder
23. Adapting an object to the IRenderer interface in order to make it render itself

    Stan Source | simple_irenderer.py

    Live example: simple IRenderer
24. More complex example of adapting objects to IRenderer and to different interfaces

    Stan Source | irenderer.py

    Live example: IRenderer
25. Handling and building a Tree structure dynamically on yor site

    Stan Source | tree.py

    Live example: tree
26. Simple example of text localisation

    Stan Source | i18n.py

    Live example: i18n
27. Localisation of disk templates

    xmlfile Source | hello.html
    Python Source | xmli18n.py

    Live example: xmli18n

# LivePage/Canvas/XUL

- TypeAhead: Using asynchronous remote method invocation from JavaScript to complete what the user is typing.

  Python Source | typeahead.py
  HTML Template | tablehtml.html

  Live example: typeahead
- Calculator: A simple server-side calculator. All button presses and calculations are processed at the server.

  Python Source | calculator.py
  HTML Template | calculator.html

  Live example: calculator
- Widgets: An example of using Athena Widgets to define custom methods for manipulating particular sections of a page's DOM, as well as communicating in both directions between the client and server.

  Python Source | widgets.py
  JavaScript Source | widgets.js

  Live example: widgets

# Tag Library Examples

- How to use the Calendar tag from the taglibrary

  Stan Source | cal.py

  Live example: calendar
- How to use the Progressbar tag from the taglibrary

  Stan Source | progress.py

  Live example: progress

# Demo Applications

- Extremely basic library, made with axiom (redesigned atop)
  xmlfile Source: with_axiom
- Handling users in a web site
  Stan Source: userdb
- Pastebin example with nevow
  Source: pastebin
- Blog engine
  Source: blogengine
- Link storage webservice (uses Twisted's XML-RPC)
  Source: postit
- Todo list with rails like file structure (requires pgasync 1.3b and postgres)
  Source: todo
- Image uploader that uses axiom
  Source: imagination