I went through the 20 minute Wiki for TG2 just now and it looks good
up to where the page.html content and root.py's new "index" function
are showed.
"blindly" following the instructions leads to a couple fairly minor
issues, which I solved as detailed below.
First I got a '"header" not defined' message, with a stack trace
indicating "${header()}" as the offending code. First I was perplexed
about how to figure out from the message what template file this came
from(any hints?) but I did find it was in the master.html, which the
tutorial does talk about.
As I researched, I found that the generated index.html included
header.html (which provides the offending header function) and also
includes sidebars and footer template code.
Then I found that footer.html relies on "now" being defined, so I put
"now" back in the dictionary passed back by the
root.RootController.index-returned dictionary. This gave me what I
expected.
so at
http://docs.turbogears.org/2.0/Wiki20/All#part-4-adding-controllers
I end up with this instead of what's there now:
-------------------------------root.py----------------------
"""Main Controller"""
from wiki20.lib.base import BaseController
from tg import expose, flash
from pylons.i18n import ugettext as _
#from tg import redirect, validate
from wiki20.model import DBSession
from wiki20.model.page import Page
# Supports the copyright date in the footer template
from datetime import datetime
now=datetime.now()
class RootController(BaseController):
@expose('wiki20.templates.page')
def index(self, pagename="FrontPage"):
page =
DBSession.query(Page).filter_by(pagename=pagename).one()
return dict(now=now,page=page)
@expose('wiki20.templates.about')
def about(self):
return dict(now=now,page='about')
--------------------------------------------------------------------
and my page.html matching the tutorial content at
http://docs.turbogears.org/2.0/Wiki20/All#part-5-adding-views-templates
looks more like
----------------------------
page.html----------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:py="http://genshi.edgewall.org/"
xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="header.html" />
<xi:include href="footer.html" />
<xi:include href="master.html" />
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"
py:replace="''"/>
<title>${page.pagename} - The TurboGears 2 Wiki</title>
</head>
<body>
<div class="main_content">
<div style="float:right; width: 10em;"> Viewing
<span py:replace="page.pagename">Page Name Goes Here</span> <br/>
You can return to the <a href="/">FrontPage</a>.
</div>
<div py:replace="page.data">Page text goes here.</div>
<a href="/edit/${page.pagename}">Edit this page</a>
</div>
</body></html>
--------------------------------------------------------------------
I hope this helps.
Bill
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---