Source

quickwiki-doc-patches / quickwiki-097.patch

Full commit
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
updating QuickWiki tutorial for 0.9.7

diff --git a/pylons/docs/en/tutorials/quickwiki_tutorial.rst b/pylons/docs/en/tutorials/quickwiki_tutorial.rst
--- a/pylons/docs/en/tutorials/quickwiki_tutorial.rst
+++ b/pylons/docs/en/tutorials/quickwiki_tutorial.rst
@@ -1,7 +1,7 @@
 .. _quickwiki_tutorial:
 
 ==================
-Quickwiki tutorial
+Quickwiki Tutorial
 ==================
 
 Introduction
@@ -9,59 +9,73 @@
 
 If you haven't done so already read the :ref:`getting_started` guide.
 
-In this tutorial we are going to create a working wiki from scratch using Pylons 0.9.6 and SQLAlchemy. Our wiki will allow visitors to add, edit or delete formatted wiki pages.
+In this tutorial we are going to create a working wiki from scratch using Pylons 0.9.7 and :term:`SQLAlchemy`. Our wiki will allow visitors to add, edit or delete formatted wiki pages. The text shows some minimal navigation of a POSIX command-line shell, and assumes that Windows users can get around in their environment.
 
 Starting at the End
 ===================
 
-Pylons is designed to be easy for everyone, not just developers, so lets start by downloading and installing the finished QuickWiki in exactly the way end users of QuickWiki might do. Once we have explored its features we will set about writing it from scratch.
+Pylons is designed to be easy for everyone, not just developers, so let's start by downloading and installing the finished QuickWiki in exactly the way others deploying your applications might do so. Once we have explored its features we will set about writing it from scratch.
 
-After you have installed `Easy Install <http://peak.telecommunity.com/DevCenter/EasyInstall>`_ run these commands to install QuickWiki and create a config file:
+Once you've consulted :ref:`getting_started` to install Pylons and :term:`setuptools`, you can run these commands to install QuickWiki and create a config file in your current working directory:
 
 .. code-block:: bash
 
-    $ easy_install QuickWiki==0.1.5
-    $ paster make-config QuickWiki test.ini
+    $ easy_install QuickWiki==0.1.6
+    $ paster make-config QuickWiki quickwiki.ini
 
-Next edit the configuration file by specifying the ``sqlalchemy.default.url`` variable in ``[app:main]`` section so that the data source name points to the database you wish to use.
+Next edit the configuration file by specifying the ``sqlalchemy.url`` variable in the ``[app:main]`` section so that the data source name points to the database you wish to use.
 
-.. Note::
+.. note::
 
-    The default ``sqlite:///%(here)s/quickwiki.db`` uses a (file-based) SQLite database named ``quickwiki.db`` in the project's top-level directory. This database will be created for you when running the ``paster setup-app`` command below, but you could also use MySQL, Oracle or PostgreSQL. Firebird and MS-SQL may also work. See the `SQLAlchemy documentation <http://www.sqlalchemy.org/docs/04/dbengine.html#dbengine_establishing>`_ for more information on how to connect to different databases. SQLite for example requires additional forward slashes in its URI, where the client/server databases should only use two. You will also need to make sure you have the appropriate Python driver for the database you wish to use. If you're using Python 2.5, a version of the `pysqlite adapter <http://www.initd.org/tracker/pysqlite/wiki/pysqlite>`_ is already included, so you can jump right in with the tutorial. You may need to get `SQLite itself <http://www.sqlite.org/download.html>`_.
+    The default ``sqlite:///production.db`` uses a (file-based) SQLite database named :file:`production.db` in the project's top-level directory. This database will be created for you when running the :command:`paster setup-app` command below, but you could also use other RDBM systems like MySQL, Oracle or PostgreSQL. See the SQLAlchemy documentation for more `information on how to connect to different databases`_. You will also need to make sure you have the appropriate Python driver for the database you wish to use. If you're using Python 2.5, a version of the `pysqlite adapter`_ is already included, so you can jump right in with the tutorial. You may need to install `SQLite itself`_.
 
-Finally create the database tables and serve the finished application:
+Finally, create the database tables and serve the finished application:
 
 .. code-block:: bash
 
-    $ paster setup-app test.ini
-    $ paster serve test.ini
+    $ paster setup-app quickwiki.ini
+    $ paster serve quickwiki.ini
 
-That's it! Now you can visit http://127.0.0.1:5000 and experiment with the finished Wiki. Note that in the title list screen you can drag page titles to the trash area to delete them via AJAX calls.
+That's it! Now you can visit http://localhost:5000 and experiment with the finished wiki.
 
-When you've finished, stop the server with ``CTRL+C`` because we will start developing our own version.
+When you've finished, stop the server with :kbd:`Ctrl+C` because we will start developing our own version.
 
-If you are interested in looking at the latest version of the QuickWiki source code it can be browsed online at http://www.knowledgetap.com/hg/QuickWiki or can be checked out using Mercurial:
+If you would like to refer to the latest version of the QuickWiki source code, it can be browsed online at http://www.knowledgetap.com/hg/QuickWiki, or can be checked out using `Mercurial`_:
 
 .. code-block:: bash
 
     $ hg clone http://www.knowledgetap.com/hg/QuickWiki
 
-.. Note::
+.. note::
 
-    To run the version checked out from the repository, you'll want to run ``python setup.py egg_info`` from the project's root directory. This will generate some files in the ``QuickWiki.egg-info`` directory.
+    To run the version checked out from the repository, you'll want to run :command:`python setup.py egg_info` from the project's root directory. This will generate some files in the :file:`QuickWiki.egg-info` directory -- because ``egg-info`` contains generated, version- and build-specific distribution metadata, you should normally exclude it from version control in your own projects.
 
-Note that there is also currently a small bug where running the command doesn't generate a ``paster_plugins.txt`` file in the ``egg-info`` directory. Without this, ``paster shell`` will not work. Create it yourself, and add the text ``Pylons``, ``WebHelpers`` and ``PasteScript`` on separate lines. Hopefully this issue will be fixed soon.
+.. _information on how to connect to different databases: http://www.sqlalchemy.org/docs/05/dbengine.html#create-engine-url-arguments
+.. _pysqlite adapter: http://www.initd.org/tracker/pysqlite/wiki/pysqlite
+.. _SQLite itself: http://www.sqlite.org/download.html
+.. _Mercurial: http://www.selenic.com/mercurial/wiki/
 
 Developing QuickWiki
 ====================
 
-If you skipped the "Starting at the End" section you will need to assure that you have Pylons installed. See the :ref:`getting_started`.
+If you skipped the `Starting at the End`_ section you will need to assure that you have Pylons installed. See :ref:`getting_started`.
 
-Then create your project:
+Begin creating your project with the following command:
 
 .. code-block:: bash
 
     $ paster create -t pylons QuickWiki
+
+Pylons features an interactive project setup script that can pre-configure your application with some common options based on your selections. You will be prompted to choose:
+
+1. which template engine you wish to use. Pylons can set up your project for Mako, Genshi or Jinja 2 out of the box. For QuickWiki, press :kbd:`Return` to accept the default, ``mako``.
+2. whether or not to configure the project for :term:`SQLAlchemy`. This will add basic database connectivity so you can begin working with model objects immediately after specifying the location of your database in a config file. Enter ``True`` and press :kbd:`Return` to continue.
+
+Alternatively, configuration options can be specified non-interactively with command line options such as:
+
+.. code-block:: bash
+
+    $ paster create -t pylons QuickWiki sqlalchemy=true template_engine=mako
 
 Now lets start the server and see what we have:
 
@@ -70,46 +84,44 @@
     $ cd QuickWiki
     $ paster serve --reload development.ini
 
-.. Note:: We have started the server with the ``--reload`` switch. This means any changes we make to code will cause the server to restart (if necessary); your changes are immediately reflected on the live site.
+.. note::
 
-Open a new console and ``cd QuickWiki/quickwiki``. Visit http://127.0.0.1:5000 where you will see the introduction page. Delete the file ``public/index.html`` because we want to see the front page of the wiki instead of this welcome page. If you now refresh the page, the Pylons built-in error document support will kick in and display an ``Error 404`` page to tell you the file could not be found. We'll setup a controller to handle this location later.
+    We have started the server with the :option:`--reload` switch. This means any changes we make to code will cause the server to restart (if necessary); your changes are immediately reflected on the live site.
+
+Open a new console and navigate to the :file:`QuickWiki/quickwiki` subdirectory of the project. Visit http://localhost:5000 where you will see the introduction page. Delete the file :file:`public/index.html` because we want to see the front page of the wiki instead of this welcome page. If you now refresh the page, the Pylons built-in error document support will kick in and display an ``Error 404`` page to tell you the file could not be found. We'll setup a controller to handle this location shortly.
 
 The Model
 =========
 
-Pylons uses a Model View Controller architecture; we'll start by creating the model. We could use any system we like for the model including `SQLObject <http://www.sqlobject.org>`_ or `SQLAlchemy <http://www.sqlalchemy.org>`_. SQLAlchemy is the default for current versions of Pylons, and we'll use it for QuickWiki.
+Pylons uses a :term:`Model-View-Controller` architecture; we'll start by creating the model, the center of our application's domain logic. You could use any persistence layer or :term:`ORM` you like for the model in your applications, like :term:`SQLAlchemy`, `Storm`_, or even `CouchDb`_ or the :term:`Google App Engine` `Datastore`_. :term:`SQLAlchemy` is commonly used by many Python developers and Pylons includes the special project template support that we've selected for QuickWiki.
 
-.. Note:: SQLAlchemy is a Python SQL toolkit and Object Relational Mapper that is quite popular among many Python programmers.
+:term:`SQLAlchemy` provides a full suite of well-known enterprise-level persistence patterns, designed for efficient and high-performance database access, adapted into a simple and Pythonic domain language. There is `full and detailed documentation`_ available on the official :term:`SQLAlchemy` website and you will want to become familiar with this before working at length with it.
 
-SQLAlchemy provides a full suite of well known enterprise-level persistence patterns, designed for efficient and high-performance database access, adapted into a simple and Pythonic domain language. There is full and detailed documentation available on the SQLAlchemy website at http://sqlalchemy.org/docs/ and you should really read this before you get heavily into SQLAlchemy.
+TODO: Once again, info on the SQLA session needs to be cleaned and clarified.
+The most basic way of using :term:`SQLAlchemy` is with explicit sessions where you create :class:`Session` objects as needed. Pylons applications typically employ a slightly more sophisticated setup using :term:`SQLAlchemy` 0.4's "contextual," thread-local sessions, via ``scoped_session``. With this configuration, the application can use a single :class:`Session` instance per web request, without the need to pass it around explicitly. Instantiating a new :class:`Session` will actually find an existing one in the current thread if available. This is also covered in the document `Using SQLAlchemy with Pylons <http://wiki.pylonshq.com/display/pylonsdocs/Using+SQLAlchemy+with+Pylons>`_, and you can learn further details in the `SQLAlchemy documentation on the Session <http://www.sqlalchemy.org/docs/04/session.html#unitofwork_contextual>`_.
 
-The most basic way of using SQLAlchemy is with explicit sessions where you create ``Session`` objects as needed. Pylons applications typically employ a slightly more sophisticated setup using SQLAlchemy 0.4's "contextual," thread-local sessions, via ``scoped_session``. With this configuration, the application can use a single ``Session`` instance per web request, without the need to pass it around explicitly. Instantiating a new ``Session`` will actually find an existing one in the current thread if available. There are further details in the `SQLAlchemy documentation on the Session <http://www.sqlalchemy.org/docs/04/session.html#unitofwork_contextual>`_.
+.. note::
 
-.. Note::
-    It is important to recognize the difference between SQLAlchemy's (or possibly another DB abstraction layer's) ``Session`` object and Pylons' standard ``session`` (with a lowercase 's') for web requests. See :mod:`beaker` for more on the latter. It is customary to reference the database session by ``model.Session`` outside of model classes.
+    It is important to recognize the difference between :term:`SQLAlchemy`'s (or possibly another DB abstraction layer's) :class:`Session` object and Pylons' standard ``session`` (with a lowercase 's') for web requests. See :mod:`beaker` for more on the latter. It is customary to reference the database session by ``model.Session`` outside of model classes.
 
-
-Now add the following to the end of the contents of your ``model/__init__.py`` file:
+Now open your :file:`model/__init__.py` file, delete the commented examples below the body of the :func:`init_model` function, and add the following in its place (taking care that it is not indented):
 
 .. code-block:: python
 
-    from sqlalchemy import Column, MetaData, Table, types
-    pages_table = Table('pages', meta.metadata,
-                    sa.Column('title', sa.types.Unicode(40), primary_key=True),
-                    sa.Column('content', sa.types.Unicode(), default='')
-                    )
+    pages_table = sa.Table('pages', meta.metadata,
+        sa.Column('title', sa.types.Unicode(40), primary_key=True),
+        sa.Column('content', sa.types.Unicode(), default='')
+    )
 
-    class Page(object):
-        pass
-
-    orm.mapper(Page, pages_table)
-
+TODO: update this...
 The first line imports Pylons' ``config`` object so we can bind our database ``Session`` to an engine -- more on that in a bit. The second line imports some useful SQLAlchemy objects such as the ``Table`` and ``Column`` classes. The third imports the mapper function which we use to map our table schemas to objects. The final import statement provides two functions for setting up the session and adding the contextual functionality.
 
-After the imports we setup our ``metadata`` object which is used when defining and managing tables. We then define a table called ``pages`` which has two columns, ``title`` (the primary key) and ``content``.
+After the imports we setup our :obj:`metadata` object which is used when defining and managing tables. We then define a table called ``pages`` which has two columns, ``title`` (the primary key) and ``content``.
 
-.. Note::
-    SQLAlchemy also supports reflecting table information directly from a database. If we had already created the ``pages`` database table, SQLAlchemy could have constructed the ``pages_table`` object for us. This uses the ``autoload=True`` parameter in place of the ``Column`` definitions, like this:
+.. note::
+
+TODO: see if this autoload stuff is still correctly shown
+    SQLAlchemy also supports reflecting table information directly from a database. If we had already created the ``pages`` database table, SQLAlchemy could have constructed the :data:`pages_table` object for us. This uses the ``autoload=True`` parameter in place of the :class:`Column` definitions, like this:
 
 .. code-block:: python
 
@@ -117,11 +129,13 @@
 
 `SQLAlchemy table reflection docs <http://www.sqlalchemy.org/docs/04/metadata.html#metadata_tables_reflecting>`_
 
-.. Note:: A primary key is a unique ID for each row in a database table. In the example above we are using the page title as a natural primary key. Some people prefer to use integer primary keys for all tables, so-called surrogate primary keys. The author of this tutorial uses both methods in his own code and is not advocating one method over the other, it is important that you choose the best database structure for your application. See the Pylons Cookbook for `a quick general overview of relational databases <http://wiki.pylonshq.com/display/pylonscookbook/Relational+databases+for+people+in+a+hurry>`_ if you're not familiar with these concepts.
+.. note::
 
-A core philosophy of SQLAlchemy is that tables and domain classes are different beasts. So next, we'll create the Python class that will represent the pages of our wiki and map these domain objects to rows in the ``pages`` table using a mapper. In a more complex application, you could break out model classes into separate ``.py`` files in your ``model`` directory, but for sake of simplicity in this case, we'll just stick to ``__init__.py``.
+    A primary key is a unique ID for each row in a database table. In the example above we are using the page title as a natural primary key. Some people prefer to use integer primary keys for all tables, so-called surrogate primary keys. The author of this tutorial uses both methods in his own code and is not advocating one method over the other, it is important that you choose the best database structure for your application. See the Pylons Cookbook for `a quick general overview of relational databases <http://wiki.pylonshq.com/display/pylonscookbook/Relational+databases+for+people+in+a+hurry>`_ if you're not familiar with these concepts.
 
-Add this to the bottom of ``model/__init__.py``:
+A core philosophy of SQLAlchemy is that tables and domain classes are different beasts. So next, we'll create the Python class that will represent the pages of our wiki and map these domain objects to rows in the ``pages`` table using a mapper. In a more complex application, you could break out model classes into separate ``.py`` files in your :file:`model` directory, but for sake of simplicity in this case, we'll just stick to :file:`__init__.py`.
+
+Add this to the bottom of :file:`model/__init__.py`:
 
 .. code-block:: python
 
@@ -129,13 +143,14 @@
         def __str__(self):
             return self.title
 
-    mapper(Page, pages_table)
+    orm.mapper(Page, pages_table)
 
 For those familiar with SQLAlchemy 0.3, ``scoped_session`` replaces the ``sessioncontext`` extension, and ``Session.mapper`` could then be used here in place of ``mapper`` to get behavior similar to what used to be achieved with ``assign_mapper``. This is considered an advanced topic, and you should consult SQLAlchemy's documentation if you wish to learn how it works.
 
+TODO: briefly introduce docutils/rst; make sure this bit isn't redundant with get_wiki_content() explanation below
 Looking ahead, our wiki will need some formatting so we will need to turn the ``content`` field into HTML. Any WikiWords (which are words made by joining together two or more lowercase words with the first letter capitalized) will also need to be converted into hyperlinks.
 
-It would be nice if we could add a method to our ``Page`` object to retrieve the formatted HTML with the WikiWords already converted to hyperlinks. Add the following at the top of the ``model/__init__.py`` file:
+It would be nice if we could add a method to our ``Page`` object to retrieve the formatted HTML with the WikiWords already converted to hyperlinks, since this is one of the most common ways that we'll be using the data in our application. Add the following imports and definitions to the top of the :file:`model/__init__.py` file:
 
 .. code-block:: python
 
@@ -147,8 +162,16 @@
     import quickwiki.lib.helpers as h
 
     wikiwords = re.compile(r"\b([A-Z]\w+[A-Z]+\w+)", re.UNICODE)
+    docutils_safety = {'file_insertion_enabled': False, 'raw_enabled': False}
 
-and then add a ``get_wiki_content()`` method to the ``Page`` object so it looks like this:
+The final definition here will be used to set options for Docutils, to to impose some security restrictions appropriate for a web application.
+
+.. seealso::
+
+    `Deploying Docutils Securely <http://docutils.sourceforge.net/docs/howto/security.html>`_
+      Further information for safely using Docutils in web application development, from Docutils' official documentation.
+
+Now let's add the :meth:`get_wiki_content()` method to the ``Page`` object, which will convert reStructuredText markup to HTML for display, as well as turning WikiWords into hyperlinks:
 
 .. code-block:: python
 
@@ -159,36 +182,38 @@
             return self.title
 
         def get_wiki_content(self):
-            content = publish_parts(
-                self.content, writer_name="html")["html_body"]
+            """Convert reStructuredText content to HTML for display, and
+            create links for WikiWords.
+            """
+            content = publish_parts(self.content, writer_name="html",
+                                    settings_overrides=docutils_safety)['html_body']
             titles = sets.Set(wikiwords.findall(content))
             for title in titles:
-                title_url = h.url_for(controller='page',
-                                      action='index', title=title)
+                title_url = url(controller='pages', action='show', title=title)
             content = content.replace(title, h.link_to(title, title_url))
             return content
 
-This code deserves a bit of explaining. The ``content = None`` line is so that the ``content`` attribute is initialized to ``None`` when a new ``Page`` object is created. The ``Page`` object represents a row in the ``pages`` table so ``self.content`` will be the value of the ``content`` field. The ``Set`` object provides us with only unique WikiWord names, so we don't try replacing them more than once (a "wikiword" is of course defined by the regular expression set globally). ``h.link_to()`` and ``h.url_for()`` are standard Pylons helpers which create links to specific controller actions. In this case we have decided that all WikiWords should link to the ``index`` action of the ``page`` controller which we will create later.
+This code deserves a bit of explaining. The ``content = None`` line is so that the ``content`` attribute is initialized to ``None`` when a new ``Page`` object is created. The ``Page`` object represents a row in the ``pages`` table so ``self.content`` will be the value of the ``content`` field. The ``Set`` object provides us with only unique WikiWord names, so we don't try replacing them more than once (a "wikiword" is of course defined by the regular expression set globally). :meth:`h.link_to()` and :meth:`h.url_for()` are standard Pylons helpers which create links to specific controller actions. In this case we have decided that all WikiWords should link to the ``index`` action of the ``page`` controller which we will create later.
 
-.. Note::
+.. note::
 
-    Pylons uses a Model View Controller architecture and so the formatting of objects into HTML should usually be handled in the view, i.e. in a template. In this example converting reStructuredText into HTML in a template is not appropriate so we are treating the HTML representation of the content as part of the model. It also gives us the chance to demonstrate that SQLAlchemy domain classes are real Python classes that can have their own methods.
+    Pylons uses a :term:`Model-View-Controller` architecture and so the formatting of objects into HTML should usually be handled in the view, i.e. in a template. In this example converting reStructuredText into HTML in a template is not appropriate so we are treating the HTML representation of the content as part of the model. It also gives us the chance to demonstrate that SQLAlchemy domain classes are real Python classes that can have their own methods.
 
-One final change, since we have used docutils and SQLAlchemy, both third party packages, we need to edit our ``setup.py`` file so that anyone installing QuickWiki with `Easy Install <http://peak.telecommunity.com/DevCenter/EasyInstall>`_ will automatically also have these dependencies installed for them too. Edit your ``setup.py`` in your project root directory so that the ``install_requires`` line looks like this:
+One final change, since we have used docutils and SQLAlchemy, both third party packages, we need to edit our :file:`setup.py` file so that anyone installing QuickWiki with `easy_install`_ will automatically also have these dependencies installed for them too. Edit your :file:`setup.py` in your project root directory so that the ``install_requires`` line looks like this:
 
 .. code-block:: python
 
-    install_requires=["Pylons>=0.9.6", "docutils==0.4", "SQLAlchemy>=0.4.1"],
+    install_requires=["Pylons>=0.9.7", "docutils==0.4", "SQLAlchemy>=0.5.0rc4"],
 
-While we are we are making changes to ``setup.py`` we might want to complete some of the other sections too. Set the version number to 0.1.5 and add a description and URL which will be used on the Python Cheeseshop when we release it:
+While we are we are making changes to :file:`setup.py` we might want to complete some of the other sections too. Set the version number to 0.1.6 and add a description and URL which will be used on the Python Cheeseshop when we release it:
 
 .. code-block:: python
 
-    version="0.1.5",
+    version="0.1.6",
     description="QuickWiki - Pylons 0.9.6 Tutorial application",
     url="http://wiki.pylonshq.com/display/pylonsdocs/QuickWiki+Tutorial",
 
-We might also want to make a full release rather than a development release in which case we would remove the following lines from ``setup.cfg``:
+We might also want to make a full release rather than a development release in which case we would remove the following lines from :file:`setup.cfg`:
 
 .. code-block:: ini
 
@@ -202,74 +227,61 @@
 
     $ python setup.py develop
 
-.. Note::
+.. note::
 
-    The command ``python setup.py develop`` installs your application in a special mode so that it behaves exactly as if it had been installed as an egg file by an end user. This is really useful when you are developing an application because it saves you having to create an egg and install it every time you want to test a change.
+    The command :command:`python setup.py develop` installs your application in a special mode so that it behaves exactly as if it had been installed as an egg file by an end user. This is really useful when you are developing an application because it saves you having to create an egg and install it every time you want to test a change.
+
+.. _Storm: http://storm.canonical.com/
+.. _CouchDB: http://couchdb.apache.org/
+.. _Datastore: http://code.google.com/appengine/docs/datastore/
+.. _full and detailed documentation: http://www.sqlalchemy.org/docs/
+.. _easy_install: http://peak.telecommunity.com/DevCenter/EasyInstall
 
 Configuration and Setup
 =======================
 
-Now lets make the changes necessary to enable QuickWiki to be set up by an end user. First, open ``environment.py`` from the ``config`` directory of your project. After ``from pylons import config``, add the following import:
-
-.. code-block:: python
-
-    from sqlalchemy import engine_from_config
-
-Then, add this line at the end of the ``load_environment`` function:
-
-.. code-block:: python
-
-    config['pylons.g'].sa_engine = \
-        engine_from_config(config, 'sqlalchemy.default.')
-
-This creates an **engine** for each instance of your application, which manages connections and is the base level at which SQLAlchemy communicates with the database. The engine is added to Pylons' ``config`` object, where you earlier saw it accessed in the ``base`` parameter for setting up SQLAlchemy's ``Session``.
-
-Now edit ``websetup.py``, used by the ``paster setup-app`` command, to look like this:
+Now lets make the changes necessary to enable QuickWiki to be set up by a user deploying your packaged application. Let's edit :file:`websetup.py`, used by the :command:`paster setup-app` command when an application is initially set up, to add some informative logging output and initialize data that the app needs out of the box:
 
 .. code-block:: python
 
     """Setup the QuickWiki application"""
     import logging
 
-    from paste.deploy import appconfig
-    from pylons import config
-
     from quickwiki.config.environment import load_environment
 
     log = logging.getLogger(__name__)
 
-    def setup_config(command, filename, section, vars):
+    def setup_app(command, conf, vars):
         """Place any commands to setup quickwiki here"""
-        conf = appconfig('config:' + filename)
         load_environment(conf.global_conf, conf.local_conf)
 
-    # Populate the DB on 'paster setup-app'
-    import quickwiki.model as model
+        # Load the models
+        from quickwiki.model import meta
+        meta.metadata.bind = meta.engine
 
-    log.info("Setting up database connectivity...")
-    engine = config['pylons.g'].sa_engine
-    log.info("Creating tables...")
-    model.metadata.create_all(bind=engine)
-    log.info("Successfully set up.")
+        # Create the tables if they aren't there already
+        log.info("Creating tables...")
+        meta.metadata.create_all(checkfirst=True)
+        log.info("Successfully set up.")
 
-    log.info("Adding front page data...")
-    page = model.Page()
-    page.title = 'FrontPage'
-    page.content = 'Welcome to the QuickWiki front page.'
-    model.Session.save(page)
-    model.Session.commit()
-    log.info("Successfully set up.")
+        import quickwiki.model as model
+        log.info("Adding front page data...")
+        page = model.Page()
+        page.title = u'FrontPage'
+        page.content = u'Welcome to the QuickWiki front page.'
+        meta.Session.add(page)
+        meta.Session.commit()
+        log.info("Successfully set up.")
 
-You can see that ``environment.py``'s ``load_environment`` function is called, so our engine is ready and we can import the model. A SQLAlchemy ``MetaData`` object--which provides some utility methods for operating on database schema--usually needs to be connected to an engine, so the line ``model.metadata.create_all(bind=engine)`` uses the engine we've set up and, well, creates the table(s) we've defined. After the tables are created the other lines add some data for the simple front page to our wiki. Because we specified ``transactional=True`` when creating our ``Session``, operations will be wrapped in a transaction and committed atomically (unless your DB doesn't support transactions, like MySQL's default MyISAM tables -- but that's beyond the scope of this tutorial).
+You can see that the :meth:`load_environment` function is called from :file:`config/environment.py`, which in turn sets up a database connection and session courtesy of code generated when you created your project. With these ready, we can import the model. A SQLAlchemy ``MetaData`` object--which provides some utility methods for operating on database schema--usually needs to be connected to an engine, so the line ``model.metadata.create_all(bind=engine)`` uses the engine we've set up and, well, creates the table(s) we've defined. After the tables are created the other lines add some data for the simple front page to our wiki. Because we specified ``transactional=True`` when creating our ``Session``, operations will be wrapped in a transaction and committed atomically (unless your DB doesn't support transactions, like MySQL's default MyISAM tables -- but that's beyond the scope of this tutorial).
 
-To test this functionality run you first need to install your QuickWiki if you haven't already done so in order for ``paster`` to find the version we are developing instead of the version we installed at the very start:
+To test this functionality run you first need to install your QuickWiki if you haven't already done so in order for :command:`paster` to find the version we are developing instead of the version we installed at the very start:
 
 .. code-block:: bash
 
     $ python setup.py develop
 
-Specify your database URI in ``development.ini`` so that the ``[app:main]`` section contains something like this, customized as needed for your database:
-
+Specify your database URI in :file:`development.ini` so that the ``[app:main]`` section contains something like this, customized as needed for your database:
 .. code-block:: ini
 
     [app:main]
@@ -280,17 +292,17 @@
     # invalidate the URI when specifying a SQLite db via path name
     sqlalchemy.default.url = sqlite:///%(here)s/quickwiki.db
 
-.. Note::
+.. note::
 
     See the SQLAlchemy note in the `Starting at the End`_ section for information on supported database URIs and a link to the SQLAlchemy documentation about the various options that can be included in them.
 
-If you want to see the SQL being generated, you can have SQLAlchemy echo it to the console by adding this line:
+If you want to see the SQL being generated, you can have :term:`SQLAlchemy` echo it to the console by adding this line:
 
 .. code-block:: ini
 
     sqlalchemy.default.echo = true
 
-You can now run the ``paster setup-app`` command to setup your tables in the same way an end user would, remembering to drop and recreate the database if the version tested earlier has already created the tables:
+You can now run the :command:`paster setup-app` command to setup your tables in the same way an end user would, remembering to drop and recreate the database if the version tested earlier has already created the tables:
 
 .. code-block:: bash
 
@@ -298,24 +310,23 @@
 
 At this stage you will need to ensure you have the appropriate Python database drivers for the database you chose, otherwise you might find SQLAlchemy complains it can't get the DBAPI module for the dialect it needs.
 
-You should also edit ``QuickWiki.egg-info/paste_deploy_config.ini_tmpl`` so that when users run ``paster make-config`` the configuration file that is produced for them will already have a section telling them to enter their own database URI as we did when we installed the finished QuickWiki at the start of the tutorial. Add these lines in the ``[app:main]`` section:
+You should also edit :file:`QuickWiki.egg-info/paste_deploy_config.ini_tmpl` so that when users run :command:`paster make-config` the configuration file that is produced for them will already have a section telling them to enter their own database URI as we did when we installed the finished QuickWiki at the start of the tutorial. Add these lines in the ``[app:main]`` section:
 
 .. code-block:: ini
 
     # Specify the database for SQLAlchemy to use.
     # %(here) may include a ':' character on Windows environments; this can
     # invalidate the URI when specifying a SQLite db via path name
-    #sqlalchemy.default.url = sqlite:///%(here)s/quickwiki.db
-    #sqlalchemy.default.echo = true
+    #sqlalchemy.url = sqlite:///%(here)s/quickwiki.db
 
 Templates
 =========
 
-.. Note::
+.. note::
 
-    Pylons uses the Mako templating language by default, although as is the case with most aspects of Pylons you are free to deviate from the default if you prefer. Pylons also supports Genshi, Kid and Cheetah out of the box.
+    Pylons installs the Mako templating language by default, although you are free to use others if you prefer. Genshi and Jinja 2 are also supported out of the box, via the project setup options discussed in the beginning of `Developing QuickWiki`_.
 
-We will make use of a feature of the Mako templating language called inheritance for our project. Add the main page template in ``templates/base.mako``:
+We will make use of a feature of the Mako templating language called inheritance for our project. Add the main page template in :file:`templates/base.mako`:
 
 .. code-block:: html+mako
 
@@ -342,16 +353,19 @@
         </body>
     </html>
 
-All our other templates will be automatically inserted into the ``${next.body()}`` line and the whole page will be returned when we call the ``render()`` global from our controller so that we can easily apply a consistent theme to all our templates.
+All our other templates will be automatically inserted into the ``${next.body()}`` line and the whole page will be returned when we call the :meth:`render()` global from our controller so that we can easily apply a consistent theme to all our templates.
 
-If you are interested in learning some of the features of Mako templates have a look at the comprehensive `Mako Documentation <http://www.makotemplates.org/docs/>`_. For now we just need to understand that next.body() is replaced with the child template and that anything within ``${...}`` brackets is executed and replaced with the result.
+If you are interested in learning some of the features of Mako templates have a look at the comprehensive `Mako Documentation`_. For now we just need to understand that ``next.body()`` is replaced with the child template and that anything within ``${...}`` brackets is executed and replaced with the result.
 
-This ``base.mako`` also makes use of various helper functions attached to the ``h`` object. These are described in the `WebHelpers documentation <http://pylonshq.com/WebHelpers/module-index.html>`_. You can add more helpers to the ``h`` object by adding them to ``lib/helpers.py`` although for this project we don't need to do so.
+TODO: clarify WebHelpers updates here
+This :file:`base.mako` also makes use of various helper functions attached to the ``h`` object. These are described in the :mod:`WebHelpers documentation <webhelpers>`. You can add more helpers to the ``h`` object by adding them to ``lib/helpers.py`` although for this project we don't need to do so.
+
+.. _Mako Documentation: http://www.makotemplates.org/docs/
 
 Routing
 =======
 
-Before we can add the actions we want to be able to route the requests to them correctly. Edit ``config/routing.py`` and adjust the 'Custom Routes' section to look like this:
+Before we can add the actions we want to be able to route the requests to them correctly. Edit :file:`config/routing.py` and adjust the 'Custom Routes' section to look like this:
 
 .. code-block:: python
 
@@ -360,7 +374,7 @@
     map.connect(':title', controller='page', action='index', title='FrontPage')
     map.connect('*url', controller='template', action='view')
 
-Note that the default route has been replaced. This tells Pylons to route the root URL ``/`` to the ``index()`` method of the ``PageController`` class in ``page.py`` and specify the ``title`` argument as ``FrontPage``. It also says that any URL of the form ``/SomePage`` should be routed to the same method but the ``title`` argument will contain the value of the first part of the URL, in this case ``SomePage``. Any other URLs which can't be matched by these maps are routed to the template controller as usual where they will result in a 404 error page being displayed.
+Note that the default route has been replaced. This tells Pylons to route the root URL ``/`` to the :meth:`index` method of the :class:`PageController` class in :file:`pages.py` and specify the ``title`` argument as ``FrontPage``. It also says that any URL of the form ``/SomePage`` should be routed to the same method but the ``title`` argument will contain the value of the first part of the URL, in this case ``SomePage``. Any other URLs which can't be matched by these maps are routed to the template controller as usual where they will result in a 404 error page being displayed.
 
 One of the main benefits of using the Routes system is that you can also create URLs automatically simply by specifying the routing arguments. For example if I want the URL for the page ``FrontPage`` I can create it with this code:
 
@@ -375,29 +389,30 @@
 Controllers
 ===========
 
-Quick Recap: We've setup the model, configured the application, added the routes and setup the base template in base.mako, now we need to write the application logic and we do this with controllers. In your project's root directory add a controller called ``page`` to your project with this command:
+Quick Recap: We've setup the model, configured the application, added the routes and setup the base template in :file:`base.mako`, now we need to write the application logic and we do this with controllers. In your project's root directory add a controller called ``pages`` to your project with this command:
 
 .. code-block:: bash
 
-    $ paster controller page
+    $ paster controller pages
 
 If you are using Subversion, this will automatically be detected and the new controller and tests will be automatically added to your subversion repository.
 
 We are going to need the following actions:
 
-``index(self, title)``
+TODO: fix meth formatting
+:meth:`index(self, title)`
 displays a page based on the title
 
-``edit(self, title)``
+:meth:`edit(self, title)`
 displays a from for editing the page ``title``
 
-``save(self, title)``
+:meth:`save(self, title)`
 save the page ``title`` and show it with a saved message
 
-``list(self)``
+:meth:`list(self)`
 gives a list of all pages
 
-``delete(self)``
+:meth:`delete(self)`
 deletes a page based on an AJAX drag and drop call
 
 Let's get cracking! We just need to make one quick preparation first: edit the ``BaseController`` class that your new page controller subclasses, so that we get a clean ``Session`` each time one of your controllers is called. Open ``lib/base.py`` and edit the ``__call__`` method like this:
@@ -420,10 +435,10 @@
 
 This is critical for avoiding unexpected and hard-to-debug behavior resulting from old session data between requests.
 
-index()
--------
+:meth:`index`
+---------------
 
-Now we can get to work on the new controller in ``page.py``. First we'll import the Page class from our model class to save some typing later on. Add this line with the imports at the top of the file:
+Now we can get to work on the new controller in :file:`pages.py`. First we'll import the Page class from our model class to save some typing later on. Add this line with the imports at the top of the file:
 
 .. code-block:: python
 
@@ -431,7 +446,7 @@
 
 This is also done the the ``base.py`` file for the Session class, as shown above. This is done sheerly for convenience, and you can instead choose to refer to ``model.Session`` and ``model.Page`` throughout your controllers, since ``BaseController`` imports the model for us. This may help to reduce confusion, especially in more complex applications.
 
-On to the ``index`` method. Replace the existing ``index()`` action with this:
+On to the ``index`` method. Replace the existing :meth:`index` action with this:
 
 .. code-block:: python
 
@@ -445,7 +460,7 @@
             return render('/new_page.mako')
         abort(404)
 
-Add a template called ``templates/page.mako`` that looks like this:
+Add a template called :file:`templates/page.mako` that looks like this:
 
 .. code-block:: html+mako
 
@@ -456,9 +471,11 @@
 
 This template simply displays the page title and content.
 
-.. Note:: Pylons automatically assigns all the action parameters to the Pylons context object ``c`` so that you don't have to assign them yourself. In this case, the value of ``title`` will be automatically assigned to ``c.title`` so that it can be used in the templates. We assign ``c.content`` manually in the controller.
+.. note::
 
-We also need a template for pages that don't already exist. It needs to display a message and link to the edit action so that they can be created. Add a template called ``templates/new_page.mako`` that looks like this:
+    Pylons automatically assigns all the action parameters to the Pylons context object ``c`` so that you don't have to assign them yourself. In this case, the value of ``title`` will be automatically assigned to ``c.title`` so that it can be used in the templates. We assign ``c.content`` manually in the controller.
+
+We also need a template for pages that don't already exist. It needs to display a message and link to the edit action so that they can be created. Add a template called :file:`templates/pages/new.mako` that looks like this:
 
 .. code-block:: html+mako
 
@@ -475,9 +492,9 @@
 
     $ paster serve --reload development.ini
 
-Visit http://127.0.0.1:5000/ and you will see the front page of the wiki. If you haven't already done so you should delete the file ``public/index.html`` so that when you visit the URL above you are routed to the correct action in the page controller and see the wiki front page instead of the ``index.html`` file being displayed.
+Visit http://localhost:5000/ and you will see the front page of the wiki. If you haven't already done so you should delete the file :file:`public/index.html` so that when you visit the URL above you are routed to the correct action in the page controller and see the wiki front page instead of the :file:`index.html` file being displayed.
 
-We can spruce it up a little by adding the stylesheet we linked to in the ``templates/base.mako`` file earlier. Add the file ``public/quick.css`` with the following content and refresh the page to reveal a better looking wiki:
+We can spruce it up a little by adding the stylesheet we linked to in the :file:`templates/base.mako` file earlier. Add the file :file:`public/quick.css` with the following content and refresh the page to reveal a better looking wiki:
 
 .. code-block:: css
 
@@ -502,12 +519,12 @@
     border-top: 1px solid #000;
     }
 
-When you run the example you will notice that the word ``QuickWiki`` has been turned into a hyperlink by the ``get_wiki_content()`` method we added to our ``Page`` domain object earlier. You can click the link and will see an example of the new page screen from the ``new_page.mako`` template. If you follow the ``Create the page`` link you will see the Pylons automatic error handler kick in to tell you ``Action edit is not implemented``. Well, we better write it next, but before we do, have a play with the :ref:`interactive_debugging`, try clicking on the ``+`` or ``>>`` arrows and you will be able to interactively debug your application. It is a tremendously useful tool.
+When you run the example you will notice that the word ``QuickWiki`` has been turned into a hyperlink by the :meth:`get_wiki_content` method we added to our :class:`Page` domain object earlier. You can click the link and will see an example of the new page screen from the :file:`new.mako` template. If you follow the ``Create the page`` link you will see the Pylons automatic error handler kick in to tell you ``Action edit is not implemented``. Well, we better write it next, but before we do, have a play with the :ref:`interactive_debugging`, try clicking on the ``+`` or ``>>`` arrows and you will be able to interactively debug your application. It is a tremendously useful tool.
 
-edit()
-------
+:meth:`edit`
+--------------
 
-To edit the wiki page we need to get the content from the database without changing it to HTML to display it in a simple form for editing. Add the ``edit()`` action:
+To edit the wiki page we need to get the content from the database without changing it to HTML to display it in a simple form for editing. Add the :meth:`edit` action:
 
 .. code-block:: python
 
@@ -518,7 +535,7 @@
             c.content = page.content
         return render('/edit.mako')
 
-and then create the ``templates/edit.mako`` file:
+and then create the :file:`templates/edit.mako` file:
 
 .. code-block:: html+mako
 
@@ -531,16 +548,18 @@
     ${h.submit(value="Save changes", name='commit')}
     ${h.end_form()}
 
-.. Note:: You might have noticed that we only set ``c.content`` if the page exists but that it is accessed in ``h.text_area`` even for pages that don't exist and yet it doesn't raise an ``AttributeError``. We are making use of the fact that the ``c`` object returns an empty string ``""`` for any attribute that is accessed which doesn't exist. This can be a very useful feature of the ``c`` object, but can catch you on occasions where you don't expect this behavior. It can be disabled by setting ``config['pylons.strict_c'] = True`` in your project's ``config/environment.py``.
+.. note::
 
-We are making use of the ``h`` object to create our form and field objects. This saves a bit of manual HTML writing. The form submits to the ``save()`` action to save the new or updated content so let's write that next.
+    You might have noticed that we only set ``c.content`` if the page exists but that it is accessed in ``h.text_area`` even for pages that don't exist and yet it doesn't raise an ``AttributeError``. We are making use of the fact that the ``c`` object returns an empty string ``""`` for any attribute that is accessed which doesn't exist. This can be a very useful feature of the ``c`` object, but can catch you on occasions where you don't expect this behavior. It can be disabled by setting ``config['pylons.strict_c'] = True`` in your project's ``config/environment.py``.
 
-save()
-------
+We are making use of the :obj:`h` object to create our form and field objects. This saves a bit of manual HTML writing. The form submits to the :meth:`save` action to save the new or updated content so let's write that next.
 
-The first thing the ``save()`` action has to do is to see if the page being saved already exists. If not it creates it with ``page = model.Page()``. Next it needs the updated content. In Pylons you can get request parameters from form submissions via GET and POST requests from the appropriately named ``request.params`` object. For form submissions from *only* GET or POST requests, use ``request.GET`` or ``request.POST``. Only POST requests should generate side effects (like changing data), so the save action will reference ``request.POST`` for the parameters.
+:meth:`save`
+--------------
 
-Add the ``save()`` action:
+The first thing the :meth:`save` action has to do is to see if the page being saved already exists. If not it creates it with ``page = model.Page()``. Next it needs the updated content. In Pylons you can get request parameters from form submissions via GET and POST requests from the appropriately named :attr:`request.params` object. For form submissions from *only* GET or POST requests, use :attr:`request.GET` or :attr:`request.POST`. Only POST requests should generate side effects (like changing data), so the save action will reference :attr:`request.POST` for the parameters.
+
+Add the :meth:`save` action:
 
 .. code-block:: python
 
@@ -558,10 +577,11 @@
         Session.commit()
         return render('/page.mako')
 
-.. Note::
-    ``request.params``, ``request.GET`` and ``request.POST`` are MultiDict objects: an ordered dictionary that may contain multiple values for each key. The MultiDict will always return one value for any existing key via the normal dict accessors ``request.params[key]`` and ``request.params.get(key)``. When multiple values are expected, use the ``request.params.getall(key)`` method to return all values in a list.
+.. note::
 
-In order for the ``page.mako`` template to display the ``Successfully saved`` message after the page is saved we need to update the ``templates/page.mako`` file. After ``<h1 class="main">${c.title}</h1>`` add these lines:
+    :attr:`request.params`, :attr:`request.GET` and :attr:`request.POST` are :class:`MultiDict` objects: an ordered dictionary that may contain multiple values for each key. The :class:`MultiDict` will always return one value for any existing key via the normal dict accessors :attr:`request.params[key]` and :meth:`request.params.get(key)`. When multiple values are expected, use the :meth:`request.params.getall(key)` method to return all values in a list.
+
+In order for the :file:`show.mako` template to display the ``Successfully saved`` message after the page is saved we need to update the :file:`templates/pages/show.mako` file. After ``<h1 class="main">${c.title}</h1>`` add these lines:
 
 .. code-block:: html+mako
 
@@ -569,7 +589,7 @@
     <p><div id="message">${c.message}</div></p>
     % endif
 
-And add the following to the ``public/quick.css`` file:
+And add the following to the :file:`public/quick.css` file:
 
 .. code-block:: css
 
@@ -577,16 +597,16 @@
         color: orangered;
     }
 
-The ``%`` syntax is used for control structures in mako -- conditionals and loops. You must 'close' them with an 'end' tag as shown here. At this point we have a fully functioning wiki that lets you create and edit pages and can be installed and deployed by an end user with just a few simple commands.
+The ``%`` syntax is used for control structures in Mako -- conditionals and loops. You must 'close' them with an 'end' tag as shown here. At this point we have a fully functioning wiki that lets you create and edit pages and can be installed and deployed by an end user with just a few simple commands.
 
-Visit http://127.0.0.1:5000 and have a play.
+Visit http://localhost:5000 and have a play.
 
-It would be nice to get a title list and to be able to delete pages, so that's what we'll do next!
+It would be nice to get a title listing and to be able to delete pages, so that's what we'll do next!
 
-list()
-------
+:meth:`list`
+--------------
 
-Add the ``list()`` action:
+Add the :meth:`list` action:
 
 .. code-block:: python
 
@@ -594,7 +614,7 @@
         c.titles = [page.title for page in Session.query(Page).all()]
         return render('/list.mako')
 
-The ``list()`` action simply gets all the pages from the database. Create the ``templates/list.mako`` file to display the list:
+The :meth:`list` action simply gets all the pages from the database. Create the :file:`templates/pages/list.mako` file to display the list:
 
 .. code-block:: html+mako
 
@@ -610,7 +630,7 @@
     % endfor
     </ul>
 
-Now we need to edit ``templates/base.mako`` to add a link to the title list in the footer, but while we're at it, let's introduce a Mako function to make the footer a little smarter. Edit ``base.mako`` like this:
+Now we need to edit :file:`templates/base.mako` to add a link to the title list in the footer, but while we're at it, let's introduce a Mako function to make the footer a little smarter. Edit :file:`base.mako` like this:
 
 .. code-block:: html+mako
 
@@ -644,24 +664,26 @@
     | ${h.link_to('Title List', h.url_for(action='list', title=None))}
     </%def>
 
-The ``<%def name="footer(action">`` creates a Mako function for display logic. As you can see, the function builds the HTML for the footer, but doesn't display the 'Edit' link when you're on the 'Title List' page or already on an edit page. It also won't show a 'Title List' link when you're already on that page. The ``<% ... %>`` tags shown on the ``return`` statement are the final new piece of Mako syntax: they're used much like the ``${...}`` tags, but for arbitrary Python code that does not directly render HTML. Also, the double hash (``##``) denotes a single-line comment in Mako.
+The ``<%def name="footer(action)">`` creates a Mako function for display logic. As you can see, the function builds the HTML for the footer, but doesn't display the 'Edit' link when you're on the 'Title List' page or already on an edit page. It also won't show a 'Title List' link when you're already on that page. The ``<% ... %>`` tags shown on the ``return`` statement are the final new piece of Mako syntax: they're used much like the ``${...}`` tags, but for arbitrary Python code that does not directly render HTML. Also, the double hash (``##``) denotes a single-line comment in Mako.
 
-So the ``footer`` function is called in place of our old 'static' footer markup. We pass it a value from ``pylons.routes_dict`` which holds the name of the action for the current request. The trailing `\\` character just tells Mako not to render an extra newline.
+So the :func:`footer` function is called in place of our old 'static' footer markup. We pass it a value from :data:`pylons.routes_dict` which holds the name of the action for the current request. The trailing `\\` character just tells Mako not to render an extra newline.
 
-If you visit http://127.0.0.1:5000/page/list you should see the full titles list and you should be able to visit each page.
+If you visit http://localhost:5000/pages you should see the full titles list and you should be able to visit each page.
 
-delete()
---------
+:meth:`delete`
+----------------
 
 Since this tutorial is designed to get you familiar with as much of Pylons core functionality as possible we will use some AJAX to allow the user to drag a title from the title list into a trash area that will automatically delete the page.
 
-Add this line to ``templates/base.mako`` before ``</head>``:
+Add this line to :file:`templates/base.mako` before ``</head>``:
 
 .. code-block:: mako
 
     ${h.javascript_include_tag('/javascripts/effects.js', builtins=True)}
 
-.. Note:: The ``h.javascript_include_tag()`` helper will create links to all the built-in JavaScripts we need and also add ``/javascripts/effects.js`` creating HTML that looks like this when you access it from a browser:
+.. note::
+
+    The ``h.javascript_include_tag()`` helper will create links to all the built-in JavaScripts we need and also add ``/javascripts/effects.js`` creating HTML that looks like this when you access it from a browser:
 
 .. code-block:: html
 
@@ -702,9 +724,11 @@
     </li>
     % endfor
 
-.. Note:: You can see that we've moved the ``for`` loop into the new template. This is so that we can easily call ``render()`` to update it via AJAX from the delete action that we'll add to our controller in just a moment. We ``<%include />`` this new template in the original ``list.mako``; this is a lot like ``<%inherit />``, but moving downward hierarchically instead of upward. It's perhaps the most basic of templating functions and is much like ``include`` in PHP templating, for example. Notice that ``list-titles.mako`` does not inherit from ``base.mako`` like the others we've created. This way we take maximal advantage of Mako's inheritance, while further reducing code duplication with ``<%include />``.
+.. note::
 
-We've also added the ``<span>`` tags, and marked each of the titles as a draggable element that reverts to its original position if it isn't dropped over a drop target. If we want to be able to delete the pages we better add a drop target. Try it out at http://127.0.0.1:5000/page/list by dragging the titles themselves around the screen. Notice how much functionality we get with just the one helper ``h.draggable_element()``.
+    You can see that we've moved the ``for`` loop into the new template. This is so that we can easily call :meth:`render` to update it via AJAX from the delete action that we'll add to our controller in just a moment. We ``<%include />`` this new template in the original ``list.mako``; this is a lot like ``<%inherit />``, but moving downward hierarchically instead of upward. It's perhaps the most basic of templating functions and is much like ``include`` in PHP templating, for example. Notice that ``list-titles.mako`` does not inherit from ``base.mako`` like the others we've created. This way we take maximal advantage of Mako's inheritance, while further reducing code duplication with ``<%include />``.
+
+We've also added the ``<span>`` tags, and marked each of the titles as a draggable element that reverts to its original position if it isn't dropped over a drop target. If we want to be able to delete the pages we better add a drop target. Try it out at http://localhost:5000/page/list by dragging the titles themselves around the screen. Notice how much functionality we get with just the one helper ``h.draggable_element()``.
 
 We better have somewhere to drop the titles to delete them, so add this before the ``<ul id="titles">`` line in ``templates/list.mako`` :
 
@@ -727,7 +751,9 @@
     padding: 15px;
     }
 
-.. Tip:: It can sometimes be very hard to debug AJAX applications. Pylons can help. If an error occurs in debug mode (the default in ``development.ini``) a debug URL where you can use an interactive debugger will be printed to the error stream, even in an AJAX request. If you copy and paste that address into a browser address bar you will be able to debug the request.
+.. tip::
+
+    It can sometimes be very hard to debug AJAX applications. Pylons can help. If an error occurs in debug mode (the default in ``development.ini``) a debug URL where you can use an interactive debugger will be printed to the error stream, even in an AJAX request. If you copy and paste that address into a browser address bar you will be able to debug the request.
 
 When a title is dropped on the ``trash`` box an AJAX request will be made to the ``delete()`` action, posting an ``id`` parameter with the ``id`` of the element that was dropped. The element with ``id`` ``titles`` will be updated with whatever is returned from the action, so we better add a ``delete()`` action that returns the new list of titles excluding the one that has been deleted:
 
@@ -744,9 +770,9 @@
 
 The title of the page is obtained from the ``id`` element and the object is loaded and then deleted. The change is saved with ``model.Session.commit()`` before the list of remaining titles is re-rendered by the template ``templates/list-titles.mako``.
 
-Visit http://127.0.0.1:5000/page/list and have a go at deleting some pages. You may need to go back to the FrontPage and create some more if you get carried away!
+Visit http://localhost:5000/page/list and have a go at deleting some pages. You may need to go back to the FrontPage and create some more if you get carried away!
 
-That's it! A working, production-ready wiki in 20 mins. You can visit http://127.0.0.1:5000/ once more to admire your work.
+That's it! A working, production-ready wiki in 20 mins. You can visit http://localhost:5000/ once more to admire your work.
 
 Publishing the Finished Product
 ===============================
@@ -757,11 +783,11 @@
 
     $ python setup.py bdist_egg
 
-This will create an egg file in ``dist`` which contains everything anyone needs to run your program. They can install it with:
+This will create an egg file in a :file:`dist` directory which contains everything anyone needs to run your program. They can install it with:
 
 .. code-block:: bash
 
-    $ easy_install QuickWiki-0.1.5-py2.5.egg
+    $ easy_install QuickWiki-0.1.6-py2.5.egg
 
 You should probably make eggs for each version of Python your users might require by running the above commands with both Python 2.4 and 2.5 to create both versions of the eggs.
 
@@ -771,13 +797,17 @@
 
     $ python setup.py register
 
-.. Warning:: The CheeseShop authentication is very weak and passwords are transmitted in plain text. Don't use any sign in details that you use for important applications as they could be easily intercepted.
+.. warning::
 
-You will be asked a number of questions and then the information you entered in ``setup.py`` will be used as a basis for the page that is created.
+    The CheeseShop authentication is very weak and passwords are transmitted in plain text. Don't use any sign in details that you use for important applications as they could be easily intercepted.
+
+You will be asked a number of questions and then the information you entered in :file:`setup.py` will be used as a basis for the page that is created.
 
 Now visit http://www.python.org/pypi to see the new index with your new package listed.
 
-.. Note:: A `CheeseShop Tutorial <http://wiki.python.org/moin/CheeseShopTutorial>`_ has been written and `full documentation on setup.py <http://docs.python.org/dist/dist.html>`_ is available from the Python website. You can even use `reStructuredText <http://docutils.sourceforge.net/rst.html>`_ in the ``description`` and ``long_description`` areas of ``setup.py`` to add formatting to the pages produced on the CheeseShop. There is also `another tutorial here <http://www.python.org/~jeremy/weblog/030924.html>`_.
+.. note::
+
+    A `CheeseShop Tutorial`_ has been written and `full documentation on setup.py`_ is available from the Python website. You can even use `reStructuredText`_ in the ``description`` and ``long_description`` areas of :file:`setup.py` to add formatting to the pages produced on the CheeseShop.
 
 Finally you can sign in to the CheeseShop with the account details you used when you registered your application and upload the eggs you've created. If that seems too difficult you can even use this command which should be run for each version of Python supported to upload the eggs for you:
 
@@ -785,7 +815,7 @@
 
     $ python setup.py bdist_egg upload
 
-Before this will work you will need to create a ``.pypirc`` file in your home directory containing your username and password so that the ``upload`` command knows who to sign in as. It should look similar to this:
+Before this will work you will need to create a :file:`.pypirc` file in your home directory containing your username and password so that the :command:`upload` command knows who to sign in as. It should look similar to this:
 
 .. code-block:: ini
 
@@ -793,31 +823,41 @@
     username: james
     password: password
 
-.. Tip:: This works on windows too but you will need to set your ``HOME`` environment variable first. If your home directory is ``C:\Documents and Settings\James`` you would put your ``.pypirc`` file in that directory and set your ``HOME`` environment variable with this command:
+.. tip::
+
+    This works on Windows too, but you will need to set your :envvar:`HOME` environment variable first. If your home directory is :file:`C:\Documents and Settings\James` you would put your :file:`.pypirc` file in that directory and set your :envvar:`HOME` environment variable with this command:
 
 .. code-block:: bash
 
     > SET HOME=C:\Documents and Settings\James
 
-You can now use the ``python setup.py bdist_egg upload`` as normal.
+You can now use the :command:`python setup.py bdist_egg upload` as normal.
 
-Now that the application is on CheeseShop anyone can install it with the ``easy_install`` command exactly as we did right at the very start of this tutorial.
+Now that the application is on CheeseShop anyone can install it with the :command:`easy_install` command exactly as we did right at the very start of this tutorial.
+
+.. _CheeseShop Tutorial: http://wiki.python.org/moin/CheeseShopTutorial
+.. _full documentation on setup.py: http://docs.python.org/dist/dist.html
+.. _reStructuredText: http://docutils.sourceforge.net/rst.html
 
 Security
 ========
 
 A final word about security.
 
-.. Danger:: Always set ``debug = false`` in configuration files for production sites and make sure your users do to.
+.. warning::
 
-You should NEVER run a production site accessible to the public with debug mode on. If there was a problem with your application and an interactive error page was shown, the visitor would be able to run any Python commands they liked in the same way you can when you are debugging. This would obviously allow them to do all sorts of malicious things so it is very important you turn off interactive debugging for production sites by setting ``debug = false`` in configuration files and also that you make users of your software do the same.
+    Always set ``debug = false`` in configuration files for production sites and make sure your users do too.
+
+You should **never** run a production site accessible to the public with debug mode on. If there was a problem with your application and an interactive error page was shown, the visitor would be able to run any Python commands they liked in the same way you can when you are debugging. This would obviously allow them to do all sorts of malicious things so it is very important you turn off interactive debugging for production sites by setting ``debug = false`` in configuration files and also that you make users of your software do the same.
 
 Summary
 =======
 
 We've gone through the whole cycle of creating and distributing a Pylons application looking at setup and configuration, routing, models, controllers and templates. Hopefully you have an idea of how powerful Pylons is and, once you get used to the concepts introduced in this tutorial, how easy it is to create sophisticated, distributable applications with Pylons.
 
-That's it, I hope you found the tutorial useful. You are encouraged to email any comments to the `Pylons mailing list <http://groups.google.co.uk/group/pylons-discuss>`_ where they will be gratefully received.
+That's it, I hope you found the tutorial useful. You are encouraged to email any comments to the `Pylons mailing list`_ where they will be gratefully received.
+
+.. _Pylons mailing list: http://groups.google.com/group/pylons-discuss
 
 ToDo
 ====