The index route works when I go to /home/index
But it doesn't work why I type /home/test
What is wrong here, very confused!
import logging
from pylons import request, response, session, tmpl_context as c, url from pylons.controllers.util import abort, redirect
from helloworld.lib.base import BaseController, render
log = logging.getLogger(name)
class HelloController(BaseController):
def index(self):
# Return a rendered template
#return render('/hello.mako')
# or, return a string
return 'Hello World from index() action!'
def test(self):
return 'blah'
I get this error:
WebError Traceback:
⇝ NotImplementedError: Action u'test' is not implemented
View as: Interactive | Text | XML (full)
URL: http://127.0.0.1:5000/hello/test
Module weberror.evalexception:431 in respond view
>> app_iter = self.application(environ, detect_start_response)
Module beaker.middleware:152 in __call__ view
>> return self.wrap_app(environ, session_start_response)
Module routes.middleware:131 in __call__ view
>> response = self.app(environ, start_response)
Module pylons.wsgiapp:107 in __call__ view
>> response = self.dispatch(controller, environ, start开发者_StackOverflow中文版_response)
Module pylons.wsgiapp:312 in dispatch view
>> return controller(environ, start_response)
Module helloworld.lib.base:15 in __call__ view
>> return WSGIController.__call__(self, environ, start_response)
Module pylons.controllers.core:211 in __call__ view
>> response = self._dispatch_call()
Module pylons.controllers.core:168 in _dispatch_call view
>> action)
NotImplementedError: Action u'test' is not implemented
Double check your indentation. If def test(self) is on the same indentation level as the class, you won't get an indentation error.
This throws an indentation error:
class HelloController(BaseController):
def index(self):
return "hello from index()"
def test(self):
return "blah"
This doesn't:
class HelloController(BaseController):
def index(self):
return "hello from index()"
def test(self):
return "blah"
精彩评论