On Fri, Mar 26, 2010 at 6:14 PM, andres <[email protected]> wrote:
> Hi Mike,
>
> Thanks for helping me figure out this problem. In case it helps,
> here's a copy of the pylons project I setup for testing:
> http://dl.dropbox.com/u/374620/myapp.tgz
>
> I have a few more questions:
>
> 1) How can I access "app.config"?
>
> 2) Can I access "app.config" outside of a WSGI app instance? I'd like
> to run scripts by loading the environment but not the app (http://
> pylonshq.com/snippets/running_commands_with_the_app_environment).
>
> 3) The out-of-the-box pylons project throws an error when you run
> nosetests on a single file:
> $ cd myapp/myapp/tests/functional
> $ nosetest test_proxy.py
>>>>     
>>>> SetupCommand('setup-app').run([pylons.test.pylonsapp.config['__file__']])
>>>> AttributeError: 'NoneType' object has no attribute 'config'

Well, you're right about ``config["mykey"]`` not working in a test
controller. I tried making a Pylons 1.0rc1 app and created a main
controller, and tried to print ``config["mykey"]`` and
``app.config["mykey"]``.  Maybe it's a new bug.

The answers to all your questions above are the same.  The ``config``
returned by load_environment() is a Pylons configuration instance, and
it's the same as ``app.config`` which is set at the bottom of
middleware.py.  ``pylons.config`` is the same but it's wrapped in a
StackedObjectProxy, which is a thread-safe, application-instance safe
way of accessing it in a regular controller.  But if you have the
config instance itself, you don't need the proxy.

You can call load_environment or make_app() yourself but they won't do
exactly what you want.  They don't parse the INI file. They expect you
to have done that already and passed the settings in as keyword args.
Only loadapp() parses the INI file.

When I run nosetests, it passes the setup-app line.So whatever error
you're getting in #3, I'm not getting.  But the error message suggests
that 'pylons.test.pylonsapp' is None. Why that would be, I don't know.

-- 
Mike Orr <[email protected]>

-- 
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