This file is indexed.

/usr/lib/python2.7/dist-packages/maasserver/json.py is in python-django-maas 1.5.4+bzr2294-0ubuntu1.2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Copyright 2013 Canonical Ltd.  This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).

"""Extension of Django's JSON serializer to support MAAS custom data types.

We register this as a replacement for Django's own JSON serialization by
setting it in the SERIALIZATION_MODULES setting.
"""

from __future__ import (
    absolute_import,
    print_function,
    unicode_literals,
    )

str = None

__metaclass__ = type
__all__ = [
    'Deserializer',
    'MAASJSONEncoder',
    'Serializer',
    ]

import django.core.serializers.json
from maasserver.fields import MAC
import simplejson


class MAASJSONEncoder(django.core.serializers.json.DjangoJSONEncoder):
    """MAAS-specific JSON encoder.

    Compared to Django's encoder, it adds support for representing a
    `MAC` in JSON.
    """

    def default(self, value):
        if isinstance(value, MAC):
            return value.get_raw()
        else:
            return super(MAASJSONEncoder, self).default(value)


class Serializer(django.core.serializers.json.Serializer):
    """A copy of Django's serializer for JSON, but using our own encoder."""
    def end_serialization(self):
        if simplejson.__version__.split('.') >= ['2', '1', '3']:
            # Use JS strings to represent Python Decimal instances
            # (ticket #16850)
            self.options.update({'use_decimal': False})
        simplejson.dump(
            self.objects, self.stream, cls=MAASJSONEncoder, **self.options)


# Keep using Django's deserializer.  Loading a MAC from JSON will produce a
# string.
Deserializer = django.core.serializers.json.Deserializer