I upgraded an application from Pylons 0.9.7 to dev (which is almost
1.0) yesterday, and I'm happy to report that it went pretty smoothly
and only took an hour or two.  I used "paster create -t pylons
AppName" and the option to make *.bak's of changed files.  Then I
looked through the differences to see what to keep from the old
version and what to add from the new.

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