Thanks for your reply!

I've tried the method you described and it doesn't seem to work
unfortunatly.
Just stressing it out.
The second i remove
map.sub_domains = True
and conditions=dict(sub_domain=['my']) from routing.py everything
starts working.

And the failure
looks like

Traceback (most recent call last):
  File "D:\Pylons\rusbiz\trunk\rusbiz\tests\functional
\test_catalog.py", line 10, in setUp
    self.login('storos', 'explore')
  File "D:\Pylons\rusbiz\trunk\rusbiz\tests\functional
\test_catalog.py", line 16, in login
    return url_for(controller='users', action='login')
  File "D:\Python25\lib\site-packages\routes-1.8-py2.5.egg\routes
\util.py", line 205, in url_for
    newargs = _screenargs(kargs)
  File "D:\Python25\lib\site-packages\routes-1.8-py2.5.egg\routes
\util.py", line 55, in _screenargs
    memory_kargs = _subdomain_check(config, memory_kargs)
  File "D:\Python25\lib\site-packages\routes-1.8-py2.5.egg\routes
\util.py", line 66, in _subdomain_check
    fullhost = config.environ.get('HTTP_HOST') or \
  File "D:\Python25\lib\site-packages\routes-1.8-py2.5.egg\routes
\__init__.py", line 14, in __getattr__
    return getattr(self.__shared_state, name)
AttributeError: 'thread._local' object has no attribute 'environ'

it occurs when i try to call url_for(controller='users',
action='login', sub_domain='my')

I can send you the sample project that displays this error

On May 13, 9:26 pm, "Kumar McMillan" <[EMAIL PROTECTED]> wrote:
> It's hard to understand what might be going on here but my only guess
> is that your app-setup code to populate the thread local config object
> is not getting run at the right time.  This is tricky to get right in
> nose because often times parts of your app want to access config
> *before* it can be imported.  What nose does is import just about
> everything in your package before it runs the tests.  If your test
> setup is done like the pylons docs suggest, that is, at the module
> level of test/__init__.py -- not within setup() -- then try this and
> see if it helps:
>
> nosetests --where=yourapp/tests
>
> that will change dir to "yourapp/tests" (adjust the path as necessary)
> and will only import from the tests directory.  However you will have
> to ensure that each test module says from yourapp import tests at the
> top so the setup code gets run.  Double check that.
>
> If that still doesn't work you'd have to revert back to a version of
> your app where tests run OK then compare the differences.  You might
> want to run nosetests --debug=nose.importer,nose.selector to help
> compare the differences in test execution.
>
> On Wed, May 7, 2008 at 8:49 AM, Pavel Skvazh <[EMAIL PROTECTED]> wrote:
>
> >  Has anyone experienced problems with running nosetests on contoller,
> >  that is routed to the sub-domain?
>
> >  Here's what I've got
>
> >  controller/test.py
> >  class TestController(BaseController):
> >         def get(self):
> >                 return True
>
> >  routing.py
> >  Out of the box
> >     map.connect(':controller/:action/:id')
> >     map.connect(':action/:id', controller='main')
> >     map.connect('*url', controller='template', action='view')
>
> >  class TestController(TestController):
> >     def test_get(self):
> >         response = self.app.get(url_for(controller='test',
> >  action='get'))
> >         r = response.body
> >         assert_true(r)
>
> >  This works just fine.
> >  What do i change
> >     map.connect(':controller/:action/:id',
> >  conditions=dict(sub_domain=['my']))
> >     map.connect(':action/:id', controller='main',
> >  conditions=dict(sub_domain=['my']))
> >     map.connect('*url', controller='template', action='view')
>
> >  I change in routing
> >     map.sub_domains = True
> >     map.sub_domains_ignore = ['www']
>
> >     map.connect(':controller/:action/:id',
> >  conditions=dict(sub_domain=['my']))
> >     map.connect(':action/:id', controller='main',
> >  conditions=dict(sub_domain=['my']))
> >     map.connect('*url', controller='template', action='view')
>
> >  And then no matter what i do in test
>
> > class TestController(TestController):
> >     def test_get(self):
> >         response = self.app.get(url_for(controller='test',
> >  action='get', sub_domain='my'))
>
> >         r = response.body
> >         assert_true(r)
>
> >  Here's what i get
> >  Traceback (most recent call last):
> >   File "\tests\functional\test.py", line 10
> >  , in setUp
> >     self.login('storos', 'explore')
> >   File "\tests\functional\test.py", line 16
> >  , in login
> >     response = self.app.post(url_for(controller='test', action='get',
> >  sub_dom
> >  ain='my'),
> >   File "D:\Python25\lib\site-packages\routes-1.8-py2.5.egg\routes
> >  \util.py", line
> >   205, in url_for
> >     newargs = _screenargs(kargs)
> >   File "D:\Python25\lib\site-packages\routes-1.8-py2.5.egg\routes
> >  \util.py", line
> >   55, in _screenargs
> >     memory_kargs = _subdomain_check(config, memory_kargs)
> >   File "D:\Python25\lib\site-packages\routes-1.8-py2.5.egg\routes
> >  \util.py", line
> >   66, in _subdomain_check
> >     fullhost = config.environ.get('HTTP_HOST') or \
> >   File "D:\Python25\lib\site-packages\routes-1.8-py2.5.egg\routes
> >  \__init__.py",
> >  line 14, in __getattr__
> >     return getattr(self.__shared_state, name)
> >  AttributeError: 'thread._local' object has no attribute 'environ'
>
> >  I cann't really figure what's going on here.
> >  return h.url_for(controller='tests', action='get', sub_domain='my')
> >  returns a perfectly legal url, so i cann't really see why test cann't
> >  see it as well
--~--~---------~--~----~------------~-------~--~----~
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