This file is indexed.

/usr/share/pyshared/lazr/restful/fields.py is in python-lazr.restful 0.19.3-0ubuntu2.

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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Copyright 2008 Canonical Ltd.  All rights reserved.

"""LAZR zope.schema.IField implementation."""

__metaclass__ = type
__all__ = [
    'CollectionField',
    'Reference',
    'ReferenceChoice',
    ]

from zope.interface import implements
from zope.schema import Choice, Field, Object
from zope.schema.interfaces import IObject, SchemaNotProvided
from zope.schema._field import AbstractCollection

from lazr.restful.interfaces import (
    ICollectionField, IReference, IReferenceChoice)


class CollectionField(AbstractCollection):
    """A collection associated with an entry."""
    # We subclass AbstractCollection instead of List because List
    # has a _type of list, and we don't want to have to implement list
    # semantics for this class.
    implements(ICollectionField)

    def __init__(self, *args, **kwargs):
        """A generic collection field.

        The readonly property defaults to True since these fields are usually
        for collections of things linked to an object, and these collections
        are managed through a dedicated API.
        """
        kwargs.setdefault('readonly', True)
        super(CollectionField, self).__init__(*args, **kwargs)


class Reference(Object):
    """An Object-like field which doesn't validate all fields of the schema.

    Unlike Object, which does call _validate_fields(self.schema, value) to
    validate all fields, this field will simply call the _validate() method of
    the Field class and then check that the given value provides the specified
    schema.
    """
    implements(IReference)

    def _validate(self, value):
        Field._validate(self, value)
        if not self.schema.providedBy(value):
            raise SchemaNotProvided()


class ReferenceChoice(Choice):
    """A choice among objects."""
    implements(IReferenceChoice)

    def __init__(self, *args, **kwargs):
        """Initialize a choice among a certain kind of object.
        This field can provide more information in a WADL description
        than a standard Choice field.

        This constructor takes the same parameters as the Choice
        constructor, plus a 'schema' keyword parameter.

        :param schema: What kind of object makes up the Choice's vocabulary.
                       The default is IObject.
        """
        schema = kwargs.pop('schema', IObject)
        self.schema = schema
        super(ReferenceChoice, self).__init__(*args, **kwargs)