The biggest change is in the config initialization. The magic
``pylons.config`` is set as late as possible. Instead, a regular
config object is passed around. (This is to make it friendlier to
nested apps.)
# environment.py
config = PylonsConfig()
config.init_app(global_conf, app_conf, package="myapp", paths=paths)
...
return config
Several middleware items now take a 'config' argument:
# middleware.py
config = load_environment(global_conf, app_conf)
app = PylonsApp(config=config)
app = SessionMiddleware(app, config)
...
app.config = config
return app
So I made these minor changes to the syntax. I removed the 'template'
argument to init_app and the CacheMiddleware, which are no longer
used. I added the 'static_files' argument to middleware.py (which
tells whether something external is serving the static files).
The next biggest change was replacing ``redirect_to(...)`` with
``redirect(url(...))``. ('redirect' is in pylons.controllers.util.
'url' is ``pylons.url``.) I went ahead and replaced all my
``h.url_for()``'s with ``ur()`` while I was at it.
I also discovered some uses of 'g' in my templates which no longer
worked, so I replaced those with 'app_globals'.
That was it, and I had a smiling, running application.
--
Mike Orr <slugg...@gmail.com>
> Mike Orr <sluggos...@gmail.com>
http://pylonsbook.com/en/1.1/exploring-pylons.html#app-globals-object
There should be a table of the special globals somewhere, but I can't
find it offhand.
'app_globals' (formerly known as 'g') is shared between threads and
requests but is unique to the application instance. This matters if
there are multiple Pylons applications running in the same process
(i.e., multiple applications under different URLs, as in /blog1 and
/blog2.) Pylons uses 'app_globals' for Mako's TemplateLookup. Some
people use it for database connections or external resources, or for a
threadlocal object, a cache of files that have been read, etc. You
can also put flags in it, especially if they're liable to change
during runtime. (Generally you don't expect 'config' variables to
change.)
This should all be put into the documentation.
--
Mike Orr <slugg...@gmail.com>