Merge lp:~gz/wikkid/support_python_2.4 into lp:wikkid

Proposed by Martin Packman
Status: Needs review
Proposed branch: lp:~gz/wikkid/support_python_2.4
Merge into: lp:wikkid
Diff against target: 147 lines (+17/-18)
8 files modified
wikkid/dispatcher.py (+2/-4)
wikkid/tests/fakes.py (+1/-1)
wikkid/tests/filestore.py (+1/-4)
wikkid/tests/views/test_root.py (+4/-3)
wikkid/user/baseuser.py (+5/-2)
wikkid/user/bzr.py (+2/-2)
wikkid/view/root.py (+1/-1)
wikkid/view/urls.py (+1/-1)
To merge this branch: bzr merge lp:~gz/wikkid/support_python_2.4
Reviewer Review Type Date Requested Status
Tim Penhey Needs Information
Review via email: mp+40584@code.launchpad.net

Description of the change

Simple set of changes that gets the test suite passing on my box. Mostly just adapting to some Python 2.4 limitations, but also an import bug and a few platform issues.

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :

Hi Martin,

I've been thinking about this quite a bit. Personally what I'd like to do here is to have wikkid trunk requiring python 2.6 as I'd like to be able to use context managers and other 2.6 features.

However, if you'd like, I could create another series of wikkid that has the 2.4 support. I'd be happy if you want to be the maintainer of that branch.

Is there a reason that you want python 2.4 support?

Tim

review: Needs Information
Revision history for this message
Martin Packman (gz) wrote :

Was trying to reproduce bug 672056 which involved running the wikkid test suite. As the failures were noisy but shallow, I fixed them rather than switch to a different box.

I don't have any particular opinion about what python versions you should support, but currently there's nothing that really needs higher than the bzrlib minimum. So, feel free to merge this then revert the 2.4 bits or just regress later on when you want to use context managers.

Unmerged revisions

58. By Martin Packman

Fix import for email.Utils.parseaddr

57. By Martin Packman

Use WebOb support for HTTP exceptions as old style classes

56. By Martin Packman

Don't test for the mime type of *.cpp files as it may vary across platforms

55. By Martin Packman

Use old style percent style interpolation rather than str.format

54. By Martin Packman

Support old location of md5 as well as new hashlib module

53. By Martin Packman

Use os.path not bzrlib.urlutils functions for platform paths to fix load_view_modules

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'wikkid/dispatcher.py'
--- wikkid/dispatcher.py 2010-06-13 11:41:41 +0000
+++ wikkid/dispatcher.py 2010-11-10 22:19:42 +0000
@@ -13,8 +13,6 @@
1313
14import os14import os
1515
16from bzrlib.urlutils import dirname, joinpath
17
18from zope.interface import providedBy16from zope.interface import providedBy
1917
2018
@@ -68,8 +66,8 @@
68# themselves with the view registry.66# themselves with the view registry.
6967
70def load_view_modules():68def load_view_modules():
71 curr_dir = os.path.abspath(dirname(__file__))69 curr_dir = os.path.abspath(os.path.dirname(__file__))
72 view_dir = joinpath(curr_dir, 'view')70 view_dir = os.path.join(curr_dir, 'view')
73 py_files = [71 py_files = [
74 filename for filename in os.listdir(view_dir)72 filename for filename in os.listdir(view_dir)
75 if filename.endswith('.py') and not filename.startswith('__')]73 if filename.endswith('.py') and not filename.startswith('__')]
7674
=== modified file 'wikkid/tests/fakes.py'
--- wikkid/tests/fakes.py 2010-05-12 10:39:13 +0000
+++ wikkid/tests/fakes.py 2010-11-10 22:19:42 +0000
@@ -23,7 +23,7 @@
23 def __init__(self, email, display_name):23 def __init__(self, email, display_name):
24 self.email = email24 self.email = email
25 self.display_name = display_name25 self.display_name = display_name
26 self.committer_id = "{0} <{1}>".format(email, display_name)26 self.committer_id = "%s <%s>" % (email, display_name)
2727
2828
29class TestRequest(object):29class TestRequest(object):
3030
=== modified file 'wikkid/tests/filestore.py'
--- wikkid/tests/filestore.py 2010-11-08 00:00:06 +0000
+++ wikkid/tests/filestore.py 2010-11-10 22:19:42 +0000
@@ -59,15 +59,12 @@
59 ('lib/', None),59 ('lib/', None),
60 ('image.jpg', 'pretend image'),60 ('image.jpg', 'pretend image'),
61 ('binary-file', 'a\0binary\0file'),61 ('binary-file', 'a\0binary\0file'),
62 ('simple.txt', 'A text file'),62 ('simple.txt', 'A text file')])
63 ('source.cpp', 'A cpp file')])
64 self.assertIs(None, filestore.get_file('lib').mimetype)63 self.assertIs(None, filestore.get_file('lib').mimetype)
65 self.assertIs(None, filestore.get_file('README').mimetype)64 self.assertIs(None, filestore.get_file('README').mimetype)
66 self.assertEqual(65 self.assertEqual(
67 'text/plain', filestore.get_file('simple.txt').mimetype)66 'text/plain', filestore.get_file('simple.txt').mimetype)
68 self.assertEqual(67 self.assertEqual(
69 'text/x-c++src', filestore.get_file('source.cpp').mimetype)
70 self.assertEqual(
71 'image/jpeg', filestore.get_file('image.jpg').mimetype)68 'image/jpeg', filestore.get_file('image.jpg').mimetype)
72 self.assertIs(None, filestore.get_file('binary-file').mimetype)69 self.assertIs(None, filestore.get_file('binary-file').mimetype)
7370
7471
=== modified file 'wikkid/tests/views/test_root.py'
--- wikkid/tests/views/test_root.py 2010-06-17 10:45:52 +0000
+++ wikkid/tests/views/test_root.py 2010-11-10 22:19:42 +0000
@@ -6,7 +6,7 @@
66
7"""Test views for the root object."""7"""Test views for the root object."""
88
9from webob.exc import HTTPSeeOther9from webob.exc import HTTPException, HTTPSeeOther
1010
11from wikkid.tests.factory import ViewTestCase11from wikkid.tests.factory import ViewTestCase
1212
@@ -19,7 +19,8 @@
19 factory = self.make_factory()19 factory = self.make_factory()
20 view = self.get_view(factory, '/')20 view = self.get_view(factory, '/')
21 error = self.assertRaises(21 error = self.assertRaises(
22 HTTPSeeOther,22 HTTPException,
23 view.render,23 view.render,
24 None)24 None)
25 self.assertEqual('/Home', error.headers['Location'])25 self.assertIsInstance(error.wsgi_response, HTTPSeeOther)
26 self.assertEqual('/Home', error.wsgi_response.headers['Location'])
2627
=== modified file 'wikkid/user/baseuser.py'
--- wikkid/user/baseuser.py 2010-05-25 22:12:26 +0000
+++ wikkid/user/baseuser.py 2010-11-10 22:19:42 +0000
@@ -9,7 +9,10 @@
9Provides the gravatar support.9Provides the gravatar support.
10"""10"""
1111
12import hashlib12try:
13 from hashlib import md5
14except ImportError:
15 from md5 import md5
1316
1417
15class BaseUser(object):18class BaseUser(object):
@@ -17,6 +20,6 @@
17 @property20 @property
18 def gravatar(self):21 def gravatar(self):
19 url = "http://www.gravatar.com/avatar/"22 url = "http://www.gravatar.com/avatar/"
20 url += hashlib.md5(self.email).hexdigest()23 url += md5(self.email).hexdigest()
21 url += "?s=50&d=identicon"24 url += "?s=50&d=identicon"
22 return url25 return url
2326
=== modified file 'wikkid/user/bzr.py'
--- wikkid/user/bzr.py 2010-06-13 11:10:54 +0000
+++ wikkid/user/bzr.py 2010-11-10 22:19:42 +0000
@@ -7,7 +7,7 @@
7"""A user factory and user class which uses the bzr identity from the7"""A user factory and user class which uses the bzr identity from the
8local bazaar config."""8local bazaar config."""
99
10import email10from email.Utils import parseaddr
11import logging11import logging
1212
13from webob import Request13from webob import Request
@@ -18,7 +18,7 @@
1818
1919
20def create_bzr_user_from_author_string(author):20def create_bzr_user_from_author_string(author):
21 name, address = email.Utils.parseaddr(author)21 name, address = parseaddr(author)
22 if name:22 if name:
23 display_name = name23 display_name = name
24 else:24 else:
2525
=== modified file 'wikkid/view/root.py'
--- wikkid/view/root.py 2010-06-17 10:45:52 +0000
+++ wikkid/view/root.py 2010-11-10 22:19:42 +0000
@@ -23,4 +23,4 @@
23 """Redirect to Home (or the default page)."""23 """Redirect to Home (or the default page)."""
24 default_resource = self.context.default_resource24 default_resource = self.context.default_resource
25 preferred = default_resource.preferred_path25 preferred = default_resource.preferred_path
26 raise HTTPSeeOther(location=preferred)26 raise HTTPSeeOther(location=preferred).exception
2727
=== modified file 'wikkid/view/urls.py'
--- wikkid/view/urls.py 2010-06-16 10:29:35 +0000
+++ wikkid/view/urls.py 2010-11-10 22:19:42 +0000
@@ -32,4 +32,4 @@
32 else:32 else:
33 if path == '/':33 if path == '/':
34 path = ''34 path = ''
35 return '{0}/+{1}'.format(path, view)35 return '%s/+%s' % (path, view)

Subscribers

People subscribed via source and target branches