Merge lp:~leonardr/launchpadlib/convert-datetime-309950 into lp:~launchpad-pqm/launchpadlib/devel
Proposed by
Leonard Richardson
Status: | Merged |
---|---|
Merged at revision: | not available |
Proposed branch: | lp:~leonardr/launchpadlib/convert-datetime-309950 |
Merge into: | lp:~launchpad-pqm/launchpadlib/devel |
To merge this branch: | bzr merge lp:~leonardr/launchpadlib/convert-datetime-309950 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Edwin Grubbs (community) | Approve | ||
Gary Poster (community) | code | Approve | |
Launchpad PQM Bot | Pending | ||
Review via email: mp+3023@code.launchpad.net |
To post a comment you must log in.
This is a launchpadlib branch that reflects changes made to a recent
wadllib branch. Some fields that used to be strings now come in as
Python datetime objects. This branch changes tests to reflect this
fact, and also makes launchpadlib capable of turning those datetime
objects back into strings when the time comes to make a PATCH or POST
request.
This branch does not deserialize dates retrieved from documents that
are the result of a named operation--that would be wadllib's job, and
right now our WADL doesn't provide the necessary tools.
=== modified file 'launchpadlib/ _browser. py' _browser. py 2008-12-05 21:38:50 +0000 _browser. py 2009-01-21 21:27:08 +0000 _oauth. oauth import ( ethod_PLAINTEXT ) _utils. json import DatetimeJSONEncoder
--- launchpadlib/
+++ launchpadlib/
@@ -43,7 +43,8 @@
from launchpadlib.errors import HTTPError
from launchpadlib.
OAuthRequest, OAuthSignatureM
-from launchpadlib._utils import uri
+from launchpadlib._utils import uri, json
+from launchpadlib.
OAUTH_REALM = 'https:/ /api.launchpad. net'
headers[ 'If-Match' ] = cached_etag
@@ -261,5 +262,5 @@
- url, simplejson.
- extra_headers=
+ url, simplejson.
+ 'PATCH', extra_headers=
=== added file 'launchpadlib/ _utils/ json.py' _utils/ json.py 1970-01-01 00:00:00 +0000 _utils/ json.py 2009-01-21 20:59:09 +0000 www.gnu. org/licenses/>. ncoder' ] oder(simplejson .JSONEncoder) : JSONEncoder. default( self, obj)
--- launchpadlib/
+++ launchpadlib/
@@ -0,0 +1,35 @@
+# Copyright 2009 Canonical Ltd.
+
+# This file is part of launchpadlib.
+#
+# launchpadlib is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# launchpadlib is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with launchpadlib. If not, see
+# <http://
+
+"""Classes for working with JSON."""
+
+__metaclass__ = type
+__all__ = ['DatetimeJSONE
+
+import datetime
+import simplejson
+
+class DatetimeJSONEnc
+ """A JSON encoder that understands datetime objects.
+
+ Datetime objects are formatted according to ISO 1601.
+ """
+ def default(self, obj):
+ if isinstance(obj, datetime.datetime):
+ return obj.isoformat()
+ return simplejson.
=== modified file 'launchpadlib/ docs/modificati ons.txt' docs/modificati ons.txt 2009-01-12 13:25:47 +0000 docs/modificati ons.txt 2009-01-21 21:10:24 +0000
--- launchpadlib/
+++ launchpadlib/
@@ -305,3 +305,26 @@
A conflicting display name
+== Data types == project. ..
+
+From the perspective of the launchpadlib user, date and date-time
+fields always look like Python datetime objects.
+
+ >>> firefox = launchpad.