Merge lp:~leonardr/lazr.restful/2.6 into lp:lazr.restful

Proposed by Leonard Richardson
Status: Merged
Approved by: Gary Poster
Approved revision: 87
Merged at revision: not available
Proposed branch: lp:~leonardr/lazr.restful/2.6
Merge into: lp:lazr.restful
Diff against target: 82 lines
4 files modified
src/lazr/restful/NEWS.txt (+5/-0)
src/lazr/restful/_resource.py (+9/-2)
src/lazr/restful/example/base/filemanager.py (+8/-2)
src/lazr/restful/version.txt (+1/-1)
To merge this branch: bzr merge lp:~leonardr/lazr.restful/2.6
Reviewer Review Type Date Requested Status
Gary Poster Approve
Review via email: mp+13653@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Leonard Richardson (leonardr) wrote :

This branch makes lazr.restful run without deprecation warnings on Python 2.6. (It also still runs on 2.4.)

I changed md5 code in the example web service to sha1 code, for the sake of consistency, but it didn't break any tests.

Revision history for this message
Gary Poster (gary) wrote :

Looks good. Thank you.

Gary

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/lazr/restful/NEWS.txt'
2--- src/lazr/restful/NEWS.txt 2009-10-19 17:27:37 +0000
3+++ src/lazr/restful/NEWS.txt 2009-10-20 17:15:20 +0000
4@@ -2,6 +2,11 @@
5 NEWS for lazr.restful
6 =====================
7
8+0.9.14 (2009-10-20)
9+===================
10+
11+lazr.restful now runs without deprecation warnings on Python 2.6.
12+
13 0.9.13 (2009-10-19)
14 ===================
15
16
17=== modified file 'src/lazr/restful/_resource.py'
18--- src/lazr/restful/_resource.py 2009-10-14 20:00:07 +0000
19+++ src/lazr/restful/_resource.py 2009-10-20 17:15:20 +0000
20@@ -33,10 +33,17 @@
21 from datetime import datetime, date
22 from gzip import GzipFile
23 import os
24-import sha
25 import simplejson
26 import zlib
27
28+# Import SHA in a way compatible with both Python 2.4 and Python 2.6.
29+try:
30+ import hashlib
31+ sha_constructor = hashlib.sha1
32+except ImportError:
33+ import sha
34+ sha_constructor = sha.new
35+
36 from zope.app.pagetemplate.engine import TrustedAppPT
37 from zope import component
38 from zope.component import (
39@@ -317,7 +324,7 @@
40 if etag_core is None:
41 return None
42
43- hash_object = sha.new()
44+ hash_object = sha_constructor()
45 hash_object.update(etag_core)
46
47 # Append the media type, so that web browsers won't treat
48
49=== modified file 'src/lazr/restful/example/base/filemanager.py'
50--- src/lazr/restful/example/base/filemanager.py 2009-09-01 14:07:03 +0000
51+++ src/lazr/restful/example/base/filemanager.py 2009-10-20 17:15:20 +0000
52@@ -7,7 +7,13 @@
53 'ManagedFileResource']
54
55 import datetime
56-import md5
57+# Import SHA in a way compatible with both Python 2.4 and Python 2.6.
58+try:
59+ import hashlib
60+ sha_constructor = hashlib.sha1
61+except ImportError:
62+ import sha
63+ sha_constructor = sha.new
64
65 from zope.interface import implements
66
67@@ -53,7 +59,7 @@
68 self.mediaType = mediaType
69 self.filename = filename
70 self.last_modified = last_modified
71- sum = md5.new()
72+ sum = sha_constructor()
73 sum.update(representation)
74 self.etag = sum.hexdigest()
75
76
77=== modified file 'src/lazr/restful/version.txt'
78--- src/lazr/restful/version.txt 2009-10-15 15:32:57 +0000
79+++ src/lazr/restful/version.txt 2009-10-20 17:15:20 +0000
80@@ -1,1 +1,1 @@
81-0.9.13
82+0.9.14

Subscribers

People subscribed via source and target branches