v0.97 of Django is compatible with python 2.4, but, as noted above the
version of sorl (which is not part of the Django that makes that
promise, but an external add-on) is not.
You have a few choices:
1. You can tar (or zip) up the stuff in site-packages/sorl on the old
box, to move to the new box. You may have to get rid of the .pyc
files. You will probably have to get rid of any .pyo and .pyd files,
and then what has been copied is probably not enough to regenerate
them (unlike the .pyc files).
2. Better would be if you could find an egg or tar file for the
version you had been running, then install that in place of the sorl
that you have.
3. You could fix the code in question:
with open(data.temporary_file_path(), 'rb') as fp:
is roughly equivalent to:
try:
fp = open(data.temporary_file_path(), 'rb')
<The code that was "inside" the "with"
finally:
fp.close()
It should (sing the file is opened for reading, and not writing) even
work without
the try-finally-close, but could consume extra memory (on average).
But there may be more stuff.
4. While it is extra work, it is easy to install more than one version
of python on, especially, a linux box. There may be a 2.5 or 2.6
package for CentOS5 somewhere. Building python from source is not
hard, but has pitfalls. The major trick to know about is that you
don't want to say "make install" at the end, but rather "make
altinstall" (documented in the python build instructions). That
performs all the same steps, except it does not link the name "python"
to the executable. Typing "python" still will get you (and all the
system management scripts that use python on a Red Hat derivative OS)
version 2.4. You have to type, for example "python2.6" to use the
other python.
Sadly, building python would mean that you also have to build
mod_wsgi, and now we are getting pretty complex, if you haven't done
that sort of things before.
By the way, you probably don't want to go all the way to python 2.7 if
you're trying to run very old python code. 2.7 introduces some
backwards incompatibilities as part of trying to persuade folks to go
to python 3.x. The one that I've hit is the fact that "as" is now a
keyword, and can't be used as a variable name ("As" can, however),
which was how it was used in a third party library that I needed.
5. You could bump to CentOS 6, and port the site to modern Django
(and other package) versions. That may sound like a lot of work, but
I suspect that it's comparable to the effort in all above but #2, and
#2 only works if you can find the package, and if there aren't other
problems with other packages. And you get additional perks, including
better maintainability, with updating to modern stuff.
Bill
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
>
https://groups.google.com/d/msg/django-users/-/FAlQ1AoMD9kJ.