Hi, I'm in the process of upgrading to Pylons 1.0 and I have some questions about runtime configuration.
According to the documentation (http://pylonshq.com/docs/en/1.0/ configuration/) the proper way to access the runtime configuration is via the pylons.config object: from pylons import config This works fine within the context of a WSGI app instance but outside the context of an app instance (e.g. testing environment), the config object is a bare-bones pylons config rather than the runtime configuration I expect. For example, if I create a simple library function to test for the presence of a runtime config key: # myapp/lib/util.py from pylons import config def has_config_key(key): return key in config then I see the following behavior when I run this test: # myapp/tests/functional/test_runtimeconfig.py from myapp.tests import TestController from myapp.lib.util import has_config_key class ConfigTest(TestController): def test_app(self): response = self.app.get(url(controller='proxy',action='util_has_config_key',key='sqlalchemy.ur')) self.assertEqual('True' in response.body, True) def test_func(self): haskey = has_config_key('sqlalchemy.url') self.assertEqual(haskey, False) This means that for code that depends on the runtime configuration but which I want to execute outside the context of an WSGI app instance I need to access the runtime configuration via a different method. One way around this problem is to avoid "pylons.config" and instead configure everything in myapp.config.environment.load_environment(). Maybe that is a better design pattern. Another option is to cache global_conf and local_conf in load_environment(). Before doing either of these things though, I wanted to make sure I wasn't missing something. How does Pylons recommend accessing the runtime configuration? Thanks, Andres -- 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.
