~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/services/webservice/json.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-06-25 08:55:37 UTC
  • mfrom: (13287.1.8 bug-800652)
  • Revision ID: launchpad@pqm.canonical.com-20110625085537-moikyoo2pe98zs7r
[r=jcsackett, julian-edwards][bug=800634,
        800652] Enable and display overrides on sync package uploads.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2011 Canonical Ltd.  This software is licensed under the
2
 
# GNU Affero General Public License version 3 (see the file LICENSE).
3
 
 
4
 
"""Additional JSON serializer for the web service."""
5
 
 
6
 
__metaclass__ = type
7
 
__all__ = [
8
 
    'StrJSONSerializer',
9
 
    ]
10
 
 
11
 
 
12
 
from lazr.restful.interfaces import IJSONPublishable
13
 
from zope.interface import implements
14
 
 
15
 
 
16
 
class StrJSONSerializer:
17
 
    """Simple JSON serializer that simply str() it's context. """
18
 
    implements(IJSONPublishable)
19
 
 
20
 
    def __init__(self, context):
21
 
        self.context = context
22
 
 
23
 
    def toDataForJSON(self, media_type):
24
 
        return str(self.context)