Pylons 1.0 compatibility

5 views
Skip to first unread message

Nick Murdoch

unread,
Jul 8, 2010, 9:29:44 AM7/8/10
to ToscaWidgets-discuss
Hi,

It seems that the ticket regarding support for later versions of
Pylons has gone unnoticed: http://toscawidgets.org/trac/tw/ticket/48

I've just run into the bug again while setting up a new Pylons 1.0
project. The patched attached to the ticket by gjhiggins still seems
to work; it'd be really useful if this could be officially released
though.

Cheers,

Nick

Paul Johnston

unread,
Jul 12, 2010, 9:11:01 AM7/12/10
to toscawidge...@googlegroups.com
Hi,

The patch looks ok. Doing this:

    if pylons.__version__ > '0.9.7':


Isn't ideal, as it wouldn't work for Pylons 0.9.11, but I think it's good enough for now.

I could commit the patch, and would be happy to do so. But I cannot manage the PyPI entry. The only people with access are Alberto and Chris P (both have been quiet lately) and "deets" who I've never heard of. Perhaps it's possible to contact PyPI and request an "admin reset", does anyone know about this?

Paul

Diez B. Roggisch

unread,
Jul 12, 2010, 9:20:58 AM7/12/10
to toscawidge...@googlegroups.com
On Monday, July 12, 2010 15:11:01 Paul Johnston wrote:
> Hi,
>
> The patch looks ok. Doing this:
>
> if pylons.__version__ > '0.9.7':
>
> Isn't ideal, as it wouldn't work for Pylons 0.9.11, but I think it's good
> enough for now.
>
> I could commit the patch, and would be happy to do so. But I cannot manage
> the PyPI entry. The only people with access are Alberto and Chris P (both
> have been quiet lately) and "deets" who I've never heard of. Perhaps it's
> possible to contact PyPI and request an "admin reset", does anyone know
> about this?


I'm deets. And the initial patch that was proposed is broken, precisely
because of the non-working version comparison.

A few month ago this was discussed between me and cd34 here, but I wasn't sure
which of the diffs which floated around was actually working.

If one of you guys sorts that out, I'm all happy releasing a new TW version to
PyPI.

Diez

Christoph Zwerschke

unread,
Jul 12, 2010, 9:44:58 AM7/12/10
to toscawidge...@googlegroups.com
Am 12.07.2010 15:11, schrieb Paul Johnston:
> The patch looks ok. Doing this:
>
> if pylons.__version__ > '0.9.7':
>
> Isn't ideal, as it wouldn't work for Pylons 0.9.11, but I think it's
> good enough for now.

Even worse, there is already Pylons 0.11.x, so string comparisons of
that version number is really not appropriate. Instead, check for the
feature that may be mssing. I.e. instead of:

if pylons.__version__ > '0.9.7':
__all__ = ["PylonsHostFramework", "validate", "render", "valid"]
else:
__all__ = ["PylonsHostFramework", "validate", "render_response",
"render", "valid"]

do this:

__all__ = ["PylonsHostFramework", "validate", "render", "valid"]

try:
from pylons.templating import render_response
except ImportError: # Pylons >= 1.0
render_response = None

if render_response:
__all__.append('render_response')

In the rest of the patch you can then simply say "if not
render_response" instead of checking for "pylons.__version__ > '0.9.7'".
This is much more readable and will not break no matter when 0.12 comes
out, not matter whether it has render_response or not.

-- Christoph

Nick Murdoch

unread,
Jul 13, 2010, 5:42:52 AM7/13/10
to ToscaWidgets-discuss
I would probably do something like

pylons_version = map(int, pylons.__version__.split('.'))
if pylons_version > [0, 9, 7]:
...
else:
...

This'll work as long as Pylons doesn't put any non-numeric characters
in its version number (which I can't imagine it would, at least not
for non-beta/dev releases).

cd34

unread,
Jul 13, 2010, 6:49:33 AM7/13/10
to ToscaWidgets-discuss
http://groups.google.com/group/toscawidgets-discuss/msg/aca58bf394675abf

already contains the proper fix by Diez that accounts for 0.10rc1,
1.0rc1, etc. using parse_version

Graham Higgins

unread,
Jul 12, 2010, 9:16:07 AM7/12/10
to toscawidge...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 12 Jul 2010, at 14:11, Paul Johnston wrote:
> Hi,
>
> The patch looks ok. Doing this:
>
> if pylons.__version__ > '0.9.7':
>
> Isn't ideal, as it wouldn't work for Pylons 0.9.11, but I think it's
> good enough for now.


I adopted Diez' more intelligent version test...

http://bitbucket.org/gjhiggins/tw-pylons/changeset/491783bc9916

- --
Cheers,

Graham

http://www.linkedin.com/in/ghiggins

-----BEGIN PGP SIGNATURE-----

iEYEARECAAYFAkw7FZcACgkQOsmLt1Nhivy4lwCfdCi3leO3CyDYnVcoVyFO1+/3
5i0AoO7Uec7+GtcSNm74cln6pLELonj2iQCUAgUBTDsVl1nrWVZ7aXD1AQLYSAP4
5VEQAYIEAL+/bYqpMtVttTZlyhSr7Mgeo3tpcvdt6DC3ojXMDre9gWclk9Kc/l+B
Ybyx1XLjvs2+P2ww/EDweShRskrDglHz2VJE3Xo1n330dyTu2iT5wrs3rK56XVrM
rWnAhx6m8lAuBcItg1tMXEMXQXZXauVgqJ8gYUvI0w==
=W42a
-----END PGP SIGNATURE-----

Graham Higgins

unread,
Jul 12, 2010, 9:28:42 AM7/12/10
to ToscaWidgets-discuss
'cos the email I just sent is taking aaaages to filter through
glooplemail.

> I'm deets. And the initial patch that was proposed is broken, precisely
> because of the non-working version comparison.

Agreed.

So, I implemented your patch... here:

http://bitbucket.org/gjhiggins/tw-pylons/changeset/491783bc9916

FWIW.

Cheers,

Graham

Graham Higgins

unread,
Jul 13, 2010, 10:19:16 AM7/13/10
to toscawidge...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 12 Jul 2010, at 14:44, Christoph Zwerschke wrote:

> check for the feature that may be mssing.

> [..]


> In the rest of the patch you can then simply say "if not
> render_response" instead of checking for "pylons.__version__ >
> '0.9.7'".
> This is much more readable and will not break no matter when 0.12
> comes
> out, not matter whether it has render_response or not.


That's what I chose to do when setuptools' bizarro version arithmetic
was drawn to my attention. Then, when Diez posted what was obviously
the Right Way To Do It, I switched to that.

Elsewhere:

> Graham said that the ML doesn't seem to work for him

spam-blocked, I suspect, otherwise web form submission of posts would
work for me and it doesn't. I have unsubbed and re-subbed using a
different email address.

Testing, testing, 1, 2, 3...


- --
Cheers,

Graham

http://www.linkedin.com/in/ghiggins


-----BEGIN PGP SIGNATURE-----

iEYEARECAAYFAkw8deQACgkQOsmLt1NhivxAXACfen/j7DWTabBOnvDS1VifC3x3
oi8An1MiyMAATn8KQo/puq3PJGtm7x9TiQCVAgUBTDx15FnrWVZ7aXD1AQI0cgP8
DKgTihj2STVW99u4D4IRpqi9cI+dH5041QzBy4Oh2aFCzK/m3oGDM2nQ+l/dpR0P
TzEvhK90Pbrm72w0x3FTT8BSzRxhadcUpbpKL/ZwQOwxgMbSpQ6WFxfGBVaGqwMG
BUsGcEiUhHbRQ99pvJ5RzOg9fCRVqD3WMT2nVJ3f8tU=
=VjY7
-----END PGP SIGNATURE-----

Reply all
Reply to author
Forward
0 new messages