Merge lp:~cmiller/desktopcouch/recorddict_more_dictly into lp:desktopcouch

Proposed by Chad Miller
Status: Merged
Approved by: Eric Casteleijn
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~cmiller/desktopcouch/recorddict_more_dictly
Merge into: lp:desktopcouch
Diff against target: 27 lines (+6/-0)
2 files modified
desktopcouch/records/record.py (+4/-0)
desktopcouch/records/tests/test_record.py (+2/-0)
To merge this branch: bzr merge lp:~cmiller/desktopcouch/recorddict_more_dictly
Reviewer Review Type Date Requested Status
Stuart Langridge (community) Approve
Eric Casteleijn (community) Approve
John O'Brien (community) Approve
Review via email: mp+18004@code.launchpad.net

Commit message

desktopcouch.record.RecordDict needs .has_key() to be more like the dict that we emulate. This sucks because dict.has_key is going away in Py 3, but let's be extra nice for another year or so.

To post a comment you must log in.
Revision history for this message
John O'Brien (jdobrien) :
review: Approve
Revision history for this message
Eric Casteleijn (thisfred) wrote :

Looks good. When the server goes to lucid, we can use an ABC, and we won't have to worry about missing API anymore.

review: Approve
Revision history for this message
Eric Casteleijn (thisfred) wrote :

(because then the server will have python 2.6)

Revision history for this message
Stuart Langridge (sil) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'desktopcouch/records/record.py'
2--- desktopcouch/records/record.py 2009-12-10 20:41:13 +0000
3+++ desktopcouch/records/record.py 2010-01-25 15:17:11 +0000
4@@ -226,6 +226,10 @@
5 self[key] = default
6 return self[key]
7
8+ def has_key(self, key):
9+ return key in self
10+
11+
12
13 class MergeableList(RecordData):
14 """An object that represents a list of complex values."""
15
16=== modified file 'desktopcouch/records/tests/test_record.py'
17--- desktopcouch/records/tests/test_record.py 2009-12-10 15:36:11 +0000
18+++ desktopcouch/records/tests/test_record.py 2010-01-25 15:17:11 +0000
19@@ -111,6 +111,8 @@
20 ['a', 'b', 'record_type', 'subfield', 'subfield_uuid'],
21 sorted(self.record.keys()))
22 self.assertIn("a", self.record)
23+ self.assertTrue(self.record.has_key("a"))
24+ self.assertFalse(self.record.has_key("f"))
25 self.assertNotIn("_id", self.record) # is internal. play dumb.
26
27 def test_application_annotations(self):

Subscribers

People subscribed via source and target branches