This file is indexed.

/usr/share/doc/python-twisted-web/examples/xmlrpc.py is in python-twisted-web 13.2.0-1ubuntu1.

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
73
74
75
76
77
78
79
80
# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.

"""
An example of an XML-RPC server in Twisted.

Usage:
    $ python xmlrpc.py

An example session (assuming the server is running):

    >>> import xmlrpclib
    >>> s = xmlrpclib.Server('http://localhost:7080/')
    >>> s.echo("lala")
    ['lala']
    >>> s.echo("lala", 1)
    ['lala', 1]
    >>> s.echo("lala", 4)
    ['lala', 4]
    >>> s.echo("lala", 4, 3.4)
    ['lala', 4, 3.3999999999999999]
    >>> s.echo("lala", 4, [1, 2])
    ['lala', 4, [1, 2]]

"""

from twisted.web import xmlrpc
from twisted.internet import defer
import xmlrpclib


class Echoer(xmlrpc.XMLRPC):
    """
    An example object to be published.

    Has five methods accessable by XML-RPC, 'echo', 'hello', 'defer',
    'defer_fail' and 'fail.
    """

    def xmlrpc_echo(self, *args):
        """
        Return all passed args.
        """
        return args

    def xmlrpc_hello(self):
        """
        Return 'hello, world'.
        """
        return 'hello, world!'

    def xmlrpc_defer(self):
        """
        Show how xmlrpc methods can return Deferred.
        """
        return defer.succeed("hello")

    def xmlrpc_defer_fail(self):
        """
        Show how xmlrpc methods can return failed Deferred.
        """
        return defer.fail(12)

    def xmlrpc_fail(self):
        """
        Show how we can return a failure code.
        """
        return xmlrpclib.Fault(7, "Out of cheese.")


def main():
    from twisted.internet import reactor
    from twisted.web import server
    r = Echoer()
    reactor.listenTCP(7080, server.Site(r))
    reactor.run()


if __name__ == '__main__':
    main()