wiki:CowsFramework/CowsInstallation/MigrationToPython2.6

Version 2 (modified by astephen, 9 years ago) (diff)

--

COWS Migration to Python 2.6 and Pylons 1.0

Introduction

In order to keep the COWS stack (cows + cowsserver + cowsclient) synchronised with our security solution we needed to update the stack to work with Python 2.6. The primary obstacle was updated the Pylons-related code due to a number of minor (but significant) changes introduced between Pylons 0.9.6 and 0.9.7. These changes are explained in the following Pylons documentation page:

 http://wiki.pylonshq.com/pages/viewpage.action?pageId=11174779

This page:

  • changes made in COWS, COWS Server and COWS Client to update to Pylons 1.0.

During this process various dependencies were also updated and documented. A separate page documents the Dependencies and Installation of the COWS stack?.

COWS modifications

The changes made to the cows library are documented in the diff between the two versions?.

The changes all related to the following change:

Replaced use of "routes.url_for" function with the global "pylons.url"
function for compatibility with pylons 1.0.

COWS Server modifications

The COWS server changes are documented in the diff between the two versions?.

These differences covered the following updates relating to Pylons changes:

1. config/middleware.py file changes

config/middleware.py file updated to mirror standard pylons 1.0 version.
Also removed the switch for compatibility with pylons versions before
version 0.9.7.

2. Setting of pylons global "c" variable config attributes (to retain previous behaviour)

Included additional config args introduced in pylons 0.9.7 to allow the
global "c" variable to maintain access to global properties and to not
throw AttributeError exceptions when an attribute is not found. See:

http://wiki.pylonshq.com/pages/viewpage.action?pageId=11174779

3. Modification of config/routing.py syntax and "map" attributes

Updated routes to pylons 1.0 requirement using new Routes syntax.
Also added the lines:

    # We need minimization switched on
    map.minimization = True
    map.explicit = False

To handle enable "implicit" routing, see:
http://routes.groovie.org/manual.html#implicit-defaults-and-route-memory 

4. Replacing "routes.url_for" with "pylons.url" calls

Replaced use of "routes.url_for" function with the global "pylons.url"
function for compatibility with pylons 1.0.

COWS Client modifications

The COWS client changes are documented in the diff between the two versions?.

These differences covered the following updates relating to Pylons changes:

1. config/middleware.py file changes

config/middleware.py file updated to mirror standard pylons 1.0 version.
Also removed the switch for compatibility with pylons versions before
version 0.9.7.

2. Setting of pylons global "c" variable config attributes (to retain previous behaviour)

Included additional config args introduced in pylons 0.9.7 to allow the
global "c" variable to maintain access to global properties and to not
throw AttributeError exceptions when an attribute is not found. See:

http://wiki.pylonshq.com/pages/viewpage.action?pageId=11174779

3. Modification of config/routing.py syntax and "map" attributes

Updated routes to pylons 1.0 requirement using new Routes syntax.
Also added the lines:

    # We need minimization switched on
    map.minimization = True
    map.explicit = False

To handle enable "implicit" routing, see:
http://routes.groovie.org/manual.html#implicit-defaults-and-route-memory 

4. Replacing "routes.url_for" with "pylons.url" calls

Replaced use of "routes.url_for" function with the global "pylons.url"
function for compatibility with pylons 1.0.

5. Escapting "<" character in Javascript within HTML template

Added CDATA section to escape the "<" character in javascript within an
HTML file. This stops Genshi escaping the "<" character into "&lt;" and
interpreting it as HTML instead of Javascript.