@@ -924,7 +924,7 @@ Instances of these classes are able to know when they've been changed.
924924
925925.. class :: incremental
926926
927- When a ZODB transaction is committed, all changes objects are saved.
927+ When a ZODB transaction is committed, all changed objects are saved.
928928
929929
930930Persistent Base Classes
@@ -1235,7 +1235,7 @@ We are ready to add views now. We'll need:
12351235* A view of the Wiki itself, which redirects to the front page.
12361236* A view of an existing Page
12371237* A view that allows us to *add * a new Page
1238- * A view that allows us to *edit * and existing Page
1238+ * A view that allows us to *edit * an existing Page
12391239
12401240.. class :: incremental
12411241
@@ -1545,7 +1545,7 @@ Update ``view_page``:
15451545
15461546 def view_page (context , request ):
15471547 # ...
1548- content = wikiwords .sub(check, content) # <- already there
1548+ content = WIKIWORDS .sub(check, content) # <- already there
15491549 edit_url = request.resource_url(context, ' edit_page' ) # <- add
15501550 return dict (page = context,
15511551 content = content,
@@ -1560,6 +1560,130 @@ Update ``view_page``:
15601560 OK
15611561
15621562
1563+ What's in the ZODB?
1564+ -------------------
1565+
1566+ We can inspect the database directly.
1567+
1568+ .. class :: incremental
1569+
1570+ Start an interactive session with:
1571+
1572+ ::
1573+
1574+ (pyramidenv)$ pshell development.ini
1575+ ...
1576+ >>> root
1577+ {'FrontPage': <wikitutorial.models.Page object at 0x1029795f0>}
1578+
1579+ .. class :: incremental small
1580+
1581+ ::
1582+
1583+ >>> root['FrontPage'].data
1584+ 'This is the front page'
1585+
1586+ .. class :: incremental small
1587+
1588+ ::
1589+
1590+ >>> root['FrontPage'].__dict__
1591+ {'__name__': 'FrontPage', 'data': 'This is the front page', '__parent__': {'FrontPage': <wikitutorial.models.Page object at 0x1029795f0>}}
1592+
1593+
1594+
1595+
1596+ Adding Templates
1597+ ----------------
1598+
1599+ What is the page template name for ``view_page ``?
1600+
1601+ .. class :: incremental
1602+
1603+ Create ``view.pt `` in your ``templates `` directory.
1604+
1605+ .. class :: incremental
1606+
1607+ Also copy the file ``base.pt `` from the class resources.
1608+
1609+ .. class :: incremental
1610+
1611+ Pyramid can use a number of different templating engines.
1612+
1613+ .. class :: incremental
1614+
1615+ We'll be using Chameleon, which also supports extending other templates.
1616+
1617+
1618+ The view.pt Template
1619+ --------------------
1620+
1621+ Type this code into your ``view.pt `` file:
1622+
1623+ .. code-block :: xml
1624+
1625+ <metal : main use-macro =" load: base.pt" >
1626+ <metal : login metal : fill-slot =" login" ></metal : login >
1627+ <metal : content metal : fill-slot =" main-content" >
1628+ <div tal : replace =" structure:content" >
1629+ Page text goes here.
1630+ </div >
1631+ <p >
1632+ <a tal : attributes =" href edit_url" href =" " >
1633+ Edit this page
1634+ </a >
1635+ </p >
1636+ </metal : content >
1637+ </metal : main >
1638+
1639+
1640+ View Your Work
1641+ --------------
1642+
1643+ We've created the following:
1644+
1645+ .. class :: incremental small
1646+
1647+ * A wiki view that redirects to the automatically-created FrontPage page
1648+ * A page view that will render the ``data `` from a page, along with a url for
1649+ editing that page
1650+ * A page template to show a wiki page.
1651+
1652+ .. class :: incremental
1653+
1654+ That's all we need to be able to see our work. Start Pyramid:
1655+
1656+ .. class :: incremental small
1657+
1658+ ::
1659+
1660+ (pyramidenv)$ pserve development.ini
1661+ Starting server in PID 43925.
1662+ serving on http://0.0.0.0:6543
1663+
1664+ .. class :: incremental
1665+
1666+ Load http://localhost:6543/
1667+
1668+
1669+ What You Should See
1670+ -------------------
1671+
1672+ .. image :: img/wiki_frontpage.png
1673+ :align: center
1674+ :width: 95%
1675+
1676+
1677+ Page Editing
1678+ ------------
1679+
1680+ You'll notice that the page has a link to ``Edit This Page ``
1681+
1682+ .. class :: incremental
1683+
1684+ If you click it, you get a 404. We haven't created that view yet.
1685+
1686+
15631687Next Steps
15641688----------
15651689
0 commit comments