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

Proposed by Martin Packman on 2010-11-10
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 2010-11-10 Needs Information on 2010-11-22
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.
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
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 on 2010-11-10

Fix import for email.Utils.parseaddr

57. By Martin Packman on 2010-11-10

Use WebOb support for HTTP exceptions as old style classes

56. By Martin Packman on 2010-11-10

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

55. By Martin Packman on 2010-11-10

Use old style percent style interpolation rather than str.format

54. By Martin Packman on 2010-11-10

Support old location of md5 as well as new hashlib module

53. By Martin Packman on 2010-11-10

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
1=== modified file 'wikkid/dispatcher.py'
2--- wikkid/dispatcher.py 2010-06-13 11:41:41 +0000
3+++ wikkid/dispatcher.py 2010-11-10 22:19:42 +0000
4@@ -13,8 +13,6 @@
5
6 import os
7
8-from bzrlib.urlutils import dirname, joinpath
9-
10 from zope.interface import providedBy
11
12
13@@ -68,8 +66,8 @@
14 # themselves with the view registry.
15
16 def load_view_modules():
17- curr_dir = os.path.abspath(dirname(__file__))
18- view_dir = joinpath(curr_dir, 'view')
19+ curr_dir = os.path.abspath(os.path.dirname(__file__))
20+ view_dir = os.path.join(curr_dir, 'view')
21 py_files = [
22 filename for filename in os.listdir(view_dir)
23 if filename.endswith('.py') and not filename.startswith('__')]
24
25=== modified file 'wikkid/tests/fakes.py'
26--- wikkid/tests/fakes.py 2010-05-12 10:39:13 +0000
27+++ wikkid/tests/fakes.py 2010-11-10 22:19:42 +0000
28@@ -23,7 +23,7 @@
29 def __init__(self, email, display_name):
30 self.email = email
31 self.display_name = display_name
32- self.committer_id = "{0} <{1}>".format(email, display_name)
33+ self.committer_id = "%s <%s>" % (email, display_name)
34
35
36 class TestRequest(object):
37
38=== modified file 'wikkid/tests/filestore.py'
39--- wikkid/tests/filestore.py 2010-11-08 00:00:06 +0000
40+++ wikkid/tests/filestore.py 2010-11-10 22:19:42 +0000
41@@ -59,15 +59,12 @@
42 ('lib/', None),
43 ('image.jpg', 'pretend image'),
44 ('binary-file', 'a\0binary\0file'),
45- ('simple.txt', 'A text file'),
46- ('source.cpp', 'A cpp file')])
47+ ('simple.txt', 'A text file')])
48 self.assertIs(None, filestore.get_file('lib').mimetype)
49 self.assertIs(None, filestore.get_file('README').mimetype)
50 self.assertEqual(
51 'text/plain', filestore.get_file('simple.txt').mimetype)
52 self.assertEqual(
53- 'text/x-c++src', filestore.get_file('source.cpp').mimetype)
54- self.assertEqual(
55 'image/jpeg', filestore.get_file('image.jpg').mimetype)
56 self.assertIs(None, filestore.get_file('binary-file').mimetype)
57
58
59=== modified file 'wikkid/tests/views/test_root.py'
60--- wikkid/tests/views/test_root.py 2010-06-17 10:45:52 +0000
61+++ wikkid/tests/views/test_root.py 2010-11-10 22:19:42 +0000
62@@ -6,7 +6,7 @@
63
64 """Test views for the root object."""
65
66-from webob.exc import HTTPSeeOther
67+from webob.exc import HTTPException, HTTPSeeOther
68
69 from wikkid.tests.factory import ViewTestCase
70
71@@ -19,7 +19,8 @@
72 factory = self.make_factory()
73 view = self.get_view(factory, '/')
74 error = self.assertRaises(
75- HTTPSeeOther,
76+ HTTPException,
77 view.render,
78 None)
79- self.assertEqual('/Home', error.headers['Location'])
80+ self.assertIsInstance(error.wsgi_response, HTTPSeeOther)
81+ self.assertEqual('/Home', error.wsgi_response.headers['Location'])
82
83=== modified file 'wikkid/user/baseuser.py'
84--- wikkid/user/baseuser.py 2010-05-25 22:12:26 +0000
85+++ wikkid/user/baseuser.py 2010-11-10 22:19:42 +0000
86@@ -9,7 +9,10 @@
87 Provides the gravatar support.
88 """
89
90-import hashlib
91+try:
92+ from hashlib import md5
93+except ImportError:
94+ from md5 import md5
95
96
97 class BaseUser(object):
98@@ -17,6 +20,6 @@
99 @property
100 def gravatar(self):
101 url = "http://www.gravatar.com/avatar/"
102- url += hashlib.md5(self.email).hexdigest()
103+ url += md5(self.email).hexdigest()
104 url += "?s=50&d=identicon"
105 return url
106
107=== modified file 'wikkid/user/bzr.py'
108--- wikkid/user/bzr.py 2010-06-13 11:10:54 +0000
109+++ wikkid/user/bzr.py 2010-11-10 22:19:42 +0000
110@@ -7,7 +7,7 @@
111 """A user factory and user class which uses the bzr identity from the
112 local bazaar config."""
113
114-import email
115+from email.Utils import parseaddr
116 import logging
117
118 from webob import Request
119@@ -18,7 +18,7 @@
120
121
122 def create_bzr_user_from_author_string(author):
123- name, address = email.Utils.parseaddr(author)
124+ name, address = parseaddr(author)
125 if name:
126 display_name = name
127 else:
128
129=== modified file 'wikkid/view/root.py'
130--- wikkid/view/root.py 2010-06-17 10:45:52 +0000
131+++ wikkid/view/root.py 2010-11-10 22:19:42 +0000
132@@ -23,4 +23,4 @@
133 """Redirect to Home (or the default page)."""
134 default_resource = self.context.default_resource
135 preferred = default_resource.preferred_path
136- raise HTTPSeeOther(location=preferred)
137+ raise HTTPSeeOther(location=preferred).exception
138
139=== modified file 'wikkid/view/urls.py'
140--- wikkid/view/urls.py 2010-06-16 10:29:35 +0000
141+++ wikkid/view/urls.py 2010-11-10 22:19:42 +0000
142@@ -32,4 +32,4 @@
143 else:
144 if path == '/':
145 path = ''
146- return '{0}/+{1}'.format(path, view)
147+ return '%s/+%s' % (path, view)

Subscribers

People subscribed via source and target branches