On Sat, Mar 27, 2010 at 1:17 PM, andres <[email protected]> wrote:
> Hi Mike,
>
> I know I'm probably missing something really simple but I don't see
> how to access the "app" variable. I see that "app.config" is being set
> in middleware.py but how can I access the "app" outside of make_app()?
>
> Also, that doesn't seem to solve the problem of accessing the runtime
> config from a standalone utility that doesn't call make_app(). It
> seems like this should should be a valid way of accessing modules
> without setting up a WSGI app:
>
> from paste.deploy import appconfig
> from myapp.config.environment import load_environment
>
> if __name__ == '__main__':
>    # Initialize the environment
>    conf = appconfig('config:development.ini', relative_to='.')
>    load_environment(conf.global_conf, conf.local_conf)
>
>    # Check runtime config
>    from pylons import config
>    assert config.has_key('mykey')

I didn't know about that ``loadconfig()`` function. It looks like it
does what i said was missing: parsing the INI file in a convenient way
without initializing the whole application.

``load_environment()`` returns ``config`` (i.e., the same object that
pylons.config proxies). So if you have that, you don't need
pylons.config.

To get the entire WSGI application (i.e., the ``app`` variable with
``app.config``):

from paste.deploy.loadwsgi import loadapp
app = loadapp("config:development.ini", relative_to=".")

Incidentally, what
> version of nostests are you using? I'm using 0.11.3.

I have 0.11.1 and 0.11.3.

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