On a fresh Pylons install (latest tip, Python 2.6, Ubuntu Karmic), no
changes to routing.py. I've added url_for to lib/helpers:

from routes import url_for

Then in my controller (home.py):

from testapp.lib.helpers import url_for

class HomeController(BaseController):
     def index(self):
         # Return a rendered template
         #return render('/home.mako')
         # or, return a string
         print url_for(controller="home", action="index")
         return 'Hello World'

Going to http://localhost:5000/home/index, I get this error:


URL: http://localhost:5000/home/index
File '/home/zeemonkee/.virtualenvs/pylons-dev/lib/python2.6/site-
packages/WebError-0.10.1-py2.6.egg/weberror/evalexception.py', line
431 in respond
  app_iter = self.application(environ, detect_start_response)
File '/home/zeemonkee/.virtualenvs/pylons-dev/lib/python2.6/site-
packages/Beaker-1.4.1-py2.6.egg/beaker/middleware.py', line 152 in
__call__
  return self.wrap_app(environ, session_start_response)
File '/home/zeemonkee/.virtualenvs/pylons-dev/lib/python2.6/site-
packages/Routes-1.12.1-py2.6.egg/routes/middleware.py', line 131 in
__call__
  response = self.app(environ, start_response)
File '/home/zeemonkee/.virtualenvs/pylons-dev/lib/python2.6/site-
packages/Pylons-1.0rc1dev_20100313-py2.6.egg/pylons/wsgiapp.py', line
107 in __call__
  response = self.dispatch(controller, environ, start_response)
File '/home/zeemonkee/.virtualenvs/pylons-dev/lib/python2.6/site-
packages/Pylons-1.0rc1dev_20100313-py2.6.egg/pylons/wsgiapp.py', line
307 in dispatch
  return controller(environ, start_response)
File '/home/zeemonkee/Downloads/testapp/testapp/lib/base.py', line 15
in __call__
  return WSGIController.__call__(self, environ, start_response)
File '/home/zeemonkee/.virtualenvs/pylons-dev/lib/python2.6/site-
packages/Pylons-1.0rc1dev_20100313-py2.6.egg/pylons/controllers/
core.py', line 211 in __call__
  response = self._dispatch_call()
File '/home/zeemonkee/.virtualenvs/pylons-dev/lib/python2.6/site-
packages/Pylons-1.0rc1dev_20100313-py2.6.egg/pylons/controllers/
core.py', line 162 in _dispatch_call
  response = self._inspect_call(func)
File '/home/zeemonkee/.virtualenvs/pylons-dev/lib/python2.6/site-
packages/Pylons-1.0rc1dev_20100313-py2.6.egg/pylons/controllers/
core.py', line 105 in _inspect_call
  result = self._perform_call(func, args)
File '/home/zeemonkee/.virtualenvs/pylons-dev/lib/python2.6/site-
packages/Pylons-1.0rc1dev_20100313-py2.6.egg/pylons/controllers/
core.py', line 57 in _perform_call
  return func(**args)
File '/home/zeemonkee/Downloads/testapp/testapp/controllers/home.py',
line 17 in indexhttp://localhost:5000/home/index#
  print url_for(controller="home", action="index")
File '/home/zeemonkee/.virtualenvs/pylons-dev/lib/python2.6/site-
packages/Routes-1.12.1-py2.6.egg/routes/util.py', line 189 in url_for
  encoding = config.mapper.encoding
File '/home/zeemonkee/.virtualenvs/pylons-dev/lib/python2.6/site-
packages/Routes-1.12.1-py2.6.egg/routes/__init__.py', line 14 in
__getattr__
  return getattr(self.__shared_state, name)
AttributeError: 'thread._local' object has no attribute 'mapper'

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" 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/pylons-discuss?hl=en.

Reply via email to