Edgewall Software

Changes between Version 38 and Version 39 of GenshiTutorial


Ignore:
Timestamp:
Aug 30, 2007, 7:31:51 PM (17 years ago)
Author:
cmlenz
Comment:

More structure

Legend:

Unmodified
Added
Removed
Modified
  • GenshiTutorial

    v38 v39  
    1515[[PageOutline(2-3, Content, inline)]]
    1616
    17 == Prerequisites ==
     17== Getting Started ==
     18
     19=== Prerequisites ===
    1820
    1921First, make sure you have !CherryPy 3.0.x installed, as well as recent versions of [http://formencode.org/ FormEncode] and obviously Genshi. You can download and install those manually, or just use [http://peak.telecommunity.com/DevCenter/EasyInstall easy_install]:
     
    2527}}}
    2628
    27 == Getting Started ==
     29=== The !CherryPy Application ===
    2830
    2931Next, set up the basic !CherryPy application.
     
    8688Note that we've configured !CherryPy to serve static files from the `geddit/static` directory. !CherryPy will complain that that directory does not exist, so create it, but leave it empty for now. We'll add static resources later on in the tutorial.
    8789
    88 == Basic Template Rendering ==
     90=== Basic Template Rendering ===
    8991
    9092So far the code doesn't actually use Genshi, or even any kind of templating. Let's change that.
     
    171173}}}
    172174
    173 == Data Model ==
     175=== The Data Model ===
    174176
    175177To continue, we'll need to first add some Python classes to define the data model the application will use. As mentioned above, we're using a simple pickle file for persistence, so all we need to do here is create a couple of very simply Python classes.
     
    268270}}}
    269271
    270 == Extending the Template ==
     272== Making the Application “Do Stuff” ==
     273
     274=== Extending the Template ===
    271275
    272276Now let's change the `Root.index()` method in `geddit/controller.py` to pass the links list to the template:
     
    508512Now, all entered values are preserved when validation errors occur. Note that the form is populated as the template is being generated, there is no reparsing and reserialization of the output.
    509513
    510 == Factoring out the Templating ==
     514== Enhancing the Application ==
     515
     516=== Factoring out the Templating ===
    511517
    512518By now, we already have some repetitive code when it comes to rendering templates: both the `Root.index()` and the `Root.submit()` methods look very similar in that regard: they load a specific template, call its `generate()` method passing it some data, and then call the `render()` method of the resulting stream. As we're going to be adding more controller methods, let's factor out those things into a library module.
     
    608614As you can see here, the code is now less repetitive: there's a simple decorator to define which template should be used, and the `render()` produces the template out stream which can then be further processed if necessary.
    609615
    610 == Adding a Layout Template ==
     616=== Adding a Layout Template ===
    611617
    612618But there's also duplication in the template files themselves: each template has to redefine the complete header and footer, and any other “decoration” markup that we may want to apply to the complete site. Now, we could simply put those commonly used markup snippets into separate HTML files and [wiki:Documentation/xml-templates.html#includes include] them in the templates where they are needed. But Genshi provides a more elegant way to apply a common structure to different templates: [wiki:Documentation/xml-templates.html#match-templates match templates].
     
    736742[[Image(tutorial03.png)]]
    737743
    738 == Implementing Comments ==
     744=== Implementing Comments ===
    739745
    740746TODO
    741747
    742 == Allowing Markup in Comments ==
     748== Advanced Topics ==
     749
     750=== Allowing Markup in Comments ===
    743751
    744752TODO
    745753
    746 == Ajaxifyied Commenting ==
     754=== Ajaxifyied Commenting ===
    747755
    748756TODO
    749757
    750 == Adding an Atom Feed ==
     758=== Adding an Atom Feed ===
    751759
    752760TODO