Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #560 (closed defect: fixed)

Opened 13 years ago

Last modified 12 years ago

Comment on docs/gettingstarted.html - code is incorrect

Reported by: nrichards at gmail dot com Owned by: anonymous
Priority: normal Milestone:
Component: Documentation Version:
Severity: normal Keywords:
Cc:

Description

The Testing, 1... 2... 3... section lists some code that doesn't work with the latest (February 11, 2006) default installations of turbogears and python.

When I hit my  http://localhost:8080/ I get the stack trace listed after the python code below, something about "welcome.py" (I only have a pyc file...? I am a newb to python fwiw.)

FROM  http://www.turbogears.org/docs/gettingstarted.html

import turbogears

class Root:

    @turbogears.expose(html="gs.templates.welcome")
    def index(self, value="0"):
        value = int(value)
        return dict(newvalue=value*2)

FROM MY SERVER

500 Internal error

Server got itself in trouble

Traceback (most recent call last):
  File "c:\bin\python24\lib\site-packages\CherryPy-2.1.1-py2.4.egg\cherrypy\_cphttptools.py", line 271, in run
    main()
  File "c:\bin\python24\lib\site-packages\CherryPy-2.1.1-py2.4.egg\cherrypy\_cphttptools.py", line 502, in main
    body = page_handler(*args, **cherrypy.request.paramMap)
  File "c:\bin\python24\lib\site-packages\TurboGears-0.8.9-py2.4.egg\turbogears\controllers.py", line 125, in newfunc
    return controllers._process_output(tg_format, output, html)
  File "c:\bin\python24\lib\site-packages\TurboGears-0.8.9-py2.4.egg\turbogears\controllers.py", line 38, in _process_output
    output = view.render(output, tg_format, template=template)
  File "c:\bin\python24\lib\site-packages\TurboGears-0.8.9-py2.4.egg\turbogears\view.py", line 97, in render
    return t.serialize(encoding="utf-8", output=format, fragment=fragment)
  File "c:\bin\python24\lib\site-packages\kid-0.8-py2.4.egg\kid\__init__.py", line 232, in serialize
    return serializer.serialize(self, encoding, fragment)
  File "c:\bin\python24\lib\site-packages\kid-0.8-py2.4.egg\kid\serialization.py", line 51, in serialize
    text = list(self.generate(stream, encoding, fragment))
  File "c:\bin\python24\lib\site-packages\kid-0.8-py2.4.egg\kid\serialization.py", line 319, in generate
    for ev, item in self.apply_filters(stream):
  File "c:\bin\python24\lib\site-packages\kid-0.8-py2.4.egg\kid\serialization.py", line 77, in balancing_filter
    for ev, item in stream:
  File "c:\bin\python24\lib\site-packages\kid-0.8-py2.4.egg\kid\pull.py", line 203, in _coalesce
    for ev, item in stream:
  File "c:\bin\python24\lib\site-packages\kid-0.8-py2.4.egg\kid\filter.py", line 21, in transform_filter
    for ev, item in apply_matches(stream, template, templates, apply_func):
  File "c:\bin\python24\lib\site-packages\kid-0.8-py2.4.egg\kid\filter.py", line 31, in apply_matches
    item = stream.expand()
  File "c:\bin\python24\lib\site-packages\kid-0.8-py2.4.egg\kid\pull.py", line 95, in expand
    for ev, item in self._iter:
  File "c:\bin\python24\lib\site-packages\kid-0.8-py2.4.egg\kid\pull.py", line 164, in _track
    for p in stream:
  File "c:\bin\python24\lib\site-packages\kid-0.8-py2.4.egg\kid\pull.py", line 203, in _coalesce
    for ev, item in stream:
  File "c:\src\web\gs\gs\templates\welcome.py", line 57, in _pull
NameError: name 'now' is not defined

Powered by Cherrypy 2.1.1

Change History

comment:1 Changed 13 years ago by anonymous

w00t just fixed my first bug in Python.

The code above, listed below the Testing... heading, should be replaced with this (set 'now'):

import turbogears

class Root:

    @turbogears.expose(html="gs.templates.welcome")
    def index(self, value="0"):
        value = int(value)
	import time
        return dict(newvalue=value*2, now=time.ctime())

comment:2 Changed 13 years ago by jorge.vargas

  • Status changed from new to closed
  • Resolution set to fixed

congrat anon next time #1 close the ticket #2 and leave your name

:)

Note: See TracTickets for help on using tickets.