What I like to do is add *args and **kwargs to controller methods,
precisely for that reason.

e.g. def index(self, expected_var, ..., *args, **kwargs):

That way I catch any extra argument passed in and I can either ignore
them or present the error in a friendlier way.

Not sure if there are better ways to do it though.

Hope this helps.
Krys

Mike Harding wrote:

>The quickstart project template has the interesting feature, inherited, I
>guess, from CherryPy...
>
>If you access 'http://localhost:8080/?var=5' you get the ugly display:
>
>Traceback (most recent call last):
>File "*/usr/local/lib/python2.4/site-packages/CherryPy-
>2.1.0_betadev-py2.4.egg/cherrypy/*_cphttptools.py", line 276, in run
>main()
>File "*/usr/local/lib/python2.4/site-packages/CherryPy-
>2.1.0_betadev-py2.4.egg/cherrypy/*_cphttptools.py", line 498, in main
>body = page_handler(*args, **cherrypy.request.paramMap)
>File 
>"/usr/local/lib/python2.4/site-packages/TurboGears-0.5.1-py2.4.egg/turbogears/controllers.py",
>line 93, in newfunc
>output = func(self, *args, **kw)
>TypeError: index() got an unexpected keyword argument 'var'
>
>Would it make sense to either have the root object take a dictionary arg, or
>explaing how to have the system catch errors such as these so they don't go
>to the screen?
>
>  
>

Reply via email to