~barry/ubuntu/natty/lazr.restful/bug-759205

« back to all changes in this revision

Viewing changes to src/lazr/restful/_operation.py

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2010-06-28 10:11:11 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100628101111-a00pkffnva3y87q9
Tags: 0.9.29-0ubuntu1
new upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
84
84
            # If the result is a web service collection, serve only one
85
85
            # batch of the collection.
86
86
            collection = getMultiAdapter((result, self.request), ICollection)
87
 
            result = CollectionResource(collection, self.request).batch()
 
87
            result = CollectionResource(collection, self.request).batch() + '}'
88
88
        elif self.should_batch(result):
89
 
            result = self.batch(result, self.request)
90
 
 
91
 
        # Serialize the result to JSON. Any embedded entries will be
92
 
        # automatically serialized.
93
 
        try:
94
 
            json_representation = simplejson.dumps(
95
 
                result, cls=ResourceJSONEncoder)
96
 
        except TypeError, e:
97
 
            raise TypeError("Could not serialize object %s to JSON." %
98
 
                            result)
 
89
            result = self.batch(result, self.request) + '}'
 
90
        else:
 
91
            # Serialize the result to JSON. Any embedded entries will be
 
92
            # automatically serialized.
 
93
            try:
 
94
                result = simplejson.dumps(result, cls=ResourceJSONEncoder)
 
95
            except TypeError, e:
 
96
                raise TypeError("Could not serialize object %s to JSON." %
 
97
                                result)
99
98
 
100
99
        self.request.response.setStatus(200)
101
100
        self.request.response.setHeader('Content-Type', self.JSON_TYPE)
102
 
        return json_representation
 
101
        return result
103
102
 
104
103
    def should_batch(self, result):
105
104
        """Whether the given response data should be batched."""