On Jun 29, 2009, at 10:35 AM, Ben Bangert wrote:
> The request specific globals are Stacked object proxies to resolve the
> issue, however if they have the same config, its possible that since
> the loading of the app occurs *before* any request is actually
> received, they both end up using the same global config object thats
> created at load-time. I believe that is what is occurring in this
> case.
Ok, I've pushed a patch to the Pylons 0.9.7.x branch that should make
it possible to setup multiple Pylons apps in the same process. From my
testing, it doesn't seem to affect existing apps, but new/existing
Pylons apps that want to be nested will need to make a few minor
changes to allow them to be nested (and avoid using the process-wide
global config).
In environment.py, the pylons.config import should be replaced with:
from pylons.configuration import PylonsConfig
First line of load_environment func should read:
config = PylonsConfig()
Last line of load_environment func should have:
return config
In middleware.py, remove the 'from pylons import config' import line.
Change the load_environment call to take the config back:
config = load_environment(global_conf, app_conf)
And finally, in middleware.py, pass that config object to PylonsApp:
app = PylonsApp(config=config)
This way, rather than the app using the process-wide global during its
initialization, it will use the locally created config object. Note
that this means if you have code elsewhere that is run during app
setup, you will need to call it from inside the load_environment
function and pass the config object to it. In the case of my test-app,
my app globals object needed keys from the config, so I changed it to
take the config as a param, and did:
config['pylons.app_globals'] = app_globals.Globals(config)
Hopefully that all makes sense?
The pylons 0.9.7.x branch can be installed from source using Mercurial:
hg clone http://bitbucket.org/bbangert/pylons/
cd pylons
hg update 0.9.7.x
python setup.py install
Or if you want to test, run:
pylon setup.py develop
Instead, you can remove the testing copy from active use with:
python setup.py develop --uninstall
Cheers,
Ben
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---