Not sure if this is a tutorial bug, or my problem...

 This issue is on page 5 :   
http://www.turbogears.org/2.0/docs/main/Wiki20/page5.html

 I follow the tutorial verbatem ( on my last failed attempt, I just
copied and pasted the modifications from the tutorial)

When I get down to the last line of page 5 I do what it says:
"When you refresh the output web page you should see “initial data”
displayed on the page."

It doesn't.

 It just shows me the same thing that was showing when I quickstarted
the project back on page 2 ( 
http://www.turbogears.org/2.0/docs/main/Wiki20/page2.html#starting-the-server
)

As proof , below are the relevant files and actions copied directly
from my project in order of the tutorial instructions


File: model/__init.py__

(tg2env)dude...@ubuntu:~/tg2env/Wiki-20/wiki20/model$ cat __init__.py#
-*- coding: utf-8 -*-
"""The application's model objects"""

from zope.sqlalchemy import ZopeTransactionExtension
from sqlalchemy.orm import scoped_session, sessionmaker
#from sqlalchemy import MetaData
from sqlalchemy.ext.declarative import declarative_base

# Global session manager: DBSession() returns the Thread-local
# session object appropriate for the current web request.
maker = sessionmaker(autoflush=True, autocommit=False,
                     extension=ZopeTransactionExtension())
DBSession = scoped_session(maker)

# Base class for all of our model classes: By default, the data model
is
# defined with SQLAlchemy's declarative extension, but if you need
more
# control, you can switch to the traditional method.
DeclarativeBase = declarative_base()

# There are two convenient ways for you to spare some typing.
# You can have a query property on all your model classes by doing
this:
# DeclarativeBase.query = DBSession.query_property()
# Or you can use a session-aware mapper as it was used in TurboGears
1:
# DeclarativeBase = declarative_base(mapper=DBSession.mapper)

# Global metadata.
# The default metadata is the one from the declarative base.
metadata = DeclarativeBase.metadata

# If you have multiple databases with overlapping table names, you'll
need a
# metadata for each database. Feel free to rename 'metadata2'.
#metadata2 = MetaData()

#####
# Generally you will not want to define your table's mappers, and data
objects
# here in __init__ but will want to create modules them in the model
directory
# and import them at the bottom of this file.
#
######

def init_model(engine):
    """Call me before using any of the tables or classes in the
model."""

    DBSession.configure(bind=engine)
    # If you are using reflection to introspect your database and
create
    # table objects for you, your tables must be defined and mapped
inside
    # the init_model function, so that the engine is available if you
    # use the model outside tg2, you need to make sure this is called
before
    # you use the model.

    #
    # See the following example:

    #global t_reflected

    #t_reflected = Table("Reflected", metadata,
    #    autoload=True, autoload_with=engine)

    #mapper(Reflected, t_reflected)

# Import your model modules here.
from wiki20.model.page import Page


File:  websetup.py

(tg2env)dude...@ubuntu:~/tg2env/Wiki-20/wiki20$ cat websetup.py
# -*- coding: utf-8 -*-
"""Setup the Wiki-20 application"""
import logging

import transaction
from tg import config

from wiki20.config.environment import load_environment

log = logging.getLogger(__name__)

def setup_app(command, conf, vars):
    """Place any commands to setup wiki20 here"""
    load_environment(conf.global_conf, conf.local_conf)
    # Load the models
    from wiki20 import model
    print "Creating tables"
    model.metadata.create_all(bind=config
['pylons.app_globals'].sa_engine)

    # Create the initial data
    print "Creating initial data"

    page = model.Page("FrontPage", "initial data")

    model.DBSession.add(page)

    transaction.commit()
    print "Successfully setup"


File:  page.py

(tg2env)dude...@ubuntu:~/tg2env/Wiki-20/wiki20/model$ cat page.py
# -*- coding: utf-8 -*-

from sqlalchemy import *
from sqlalchemy import Column
from sqlalchemy.types import Integer, Text

#from sqlalchemy.orm import relation, backref

from wiki20.model import DeclarativeBase

class Page(DeclarativeBase):
    __tablename__ = 'pages'

    id=Column(Integer, primary_key=True)
    pagename=Column(Text, unique=True)
    data=Column(Text)

    def __init__(self, pagename, data):
        self.pagename = pagename
        self.data = data


File:  websetup.py

(tg2env)dude...@ubuntu:~/tg2env/Wiki-20/wiki20$ cat websetup.py
# -*- coding: utf-8 -*-
"""Setup the Wiki-20 application"""
import logging

import transaction
from tg import config

from wiki20.config.environment import load_environment

log = logging.getLogger(__name__)

def setup_app(command, conf, vars):
    """Place any commands to setup wiki20 here"""
    load_environment(conf.global_conf, conf.local_conf)
    # Load the models
    from wiki20 import model
    print "Creating tables"
    model.metadata.create_all(bind=config
['pylons.app_globals'].sa_engine)

    # Create the initial data
    print "Creating initial data"

    page = model.Page("FrontPage", "initial data")

    model.DBSession.add(page)

    transaction.commit()
    print "Successfully setup"


ACTION:  Now run the paster setup-app command in your root directory:

PROOF I DID THIS:
tg2env)dude...@ubuntu:~/tg2env/Wiki-20$ sqlite3 -line devdata.db
'select * from pages;'
      id = 1
pagename = FrontPage
    data = initial data


FILE:  controllers/root.py

(tg2env)dude...@ubuntu:~/tg2env/Wiki-20/wiki20/controllers$ cat
root.py
# -*- coding: utf-8 -*-
"""Main Controller"""
from wiki20.lib.base import BaseController
from tg import expose, flash, require, url, request, redirect
from pylons.i18n import ugettext as _, lazy_ugettext as l_
#from tg import redirect, validate
from wiki20.model import DBSession, metadata
from wiki20.controllers.error import ErrorController
from wiki20.model.page import Page

class RootController(BaseController):
    error = ErrorController()

    @expose('wiki20.templates.page')
    def index(self, pagename="FrontPage"):
        page = DBSession.query(Page).filter_by(pagename=pagename).one
()
        return dict(wikipage=page)

    @expose('wiki20.templates.about')
    def about(self):
        return dict(page='about')


FILE:  wiki20/templates/page.html

(tg2env)dude...@ubuntu:~/tg2env/Wiki-20/wiki20/templates$ cat
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="master.html" />

<head>
  <meta content="text/html; charset=utf-8" http-equiv="Content-Type"
py:replace="''"/>
  <title>${wikipage.pagename} - The TurboGears 2 Wiki</title>
</head>

<body>
  <div class="main_content">
     <div style="float:right; width: 10em;"> Viewing
        <span py:replace="wikipage.pagename">Page Name Goes Here</
span>
        <br/>
        You can return to the <a href="/">FrontPage</a>.
  </div>
  <div py:replace="wikipage.data">Page text goes here.</div>
     <a href="/edit/${wikipage.pagename}">Edit this page</a>
  </div>
</body>
</html>



ACTION:   I them open a new browser  and go to 127.0.0.1:8080  and I
still see the old page.  None of the "initial data" is displayed.

PROOF I DID IT:

I installed elinks - a text web browser.
I used elinks to go to 127.0.0.1:8080 and  saved the displayed screen
as a formatted page names 127001800

I then cat the file and got:

dude...@ubuntu:~$ dir
127001800  Documents    Music     Public     tg2env
Desktop    ez_setup.py  Pictures  Templates  Videos
dude...@ubuntu:~$ cat 127001800
              Welcome to TurboGears 2 The Python web metaframework

     * Welcome
     * About
     * Contact

   Now Viewing: index

Get Started with TG2

     * About this page A quick guide to this TG2 site
     * TG2 Documents - Read everything in the Getting Started section
     * TG1 docs (still useful, although a lot has changed for TG2)
     * Join the TG Mail List for general TG use/topics

Presentation

   TurboGears 2 is rapid web application development toolkit designed
to make
   your life easier.

    1. Code your data model

       Design your data model, Create the database, and Add some
bootstrap
       data.

    2. Design your URL architecture

       Decide your URLs, Program your controller methods, Design your
       templates, and place some static files (CSS and/or JavaScript).

    3. Distribute your app

       Test your source, Generate project documents, Build a
distribution.

   Thank you for choosing TurboGears.
   TurboGears

   Powered by TurboGears 2

   TurboGears is a open source front-to-back web development framework
   written in Python. Copyright (c) 2005-2008

References

   Visible links
   . http://127.0.0.1:8080/
   . http://127.0.0.1:8080/about
   . http://groups.google.com/group/turbogears
   . http://127.0.0.1:8080/about
   . http://www.turbogears.org/2.0/docs/
   . http://docs.turbogears.org/1.0
   . http://groups.google.com/group/turbogears
   . http://www.turbogears.org/2.0/
dude...@ubuntu:~$



Any thoughts ?

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to