This file is indexed.

/usr/share/pyshared/zope/ptresource/ptresource.py is in python-zope.ptresource 3.9.0-0ubuntu5.

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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Page Template Resource

$Id: ptresource.py 103139 2009-08-24 11:58:22Z nadako $
"""

from zope.interface import implements, classProvides
from zope.pagetemplate.engine import TrustedAppPT
from zope.pagetemplate.pagetemplatefile import PageTemplateFile
from zope.publisher.browser import BrowserView
from zope.publisher.interfaces import NotFound
from zope.publisher.interfaces.browser import IBrowserPublisher

from zope.browserresource.resource import Resource
from zope.browserresource.interfaces import IResourceFactory
from zope.browserresource.interfaces import IResourceFactoryFactory

class PageTemplate(TrustedAppPT, PageTemplateFile):
    """
    Resource that is a page template
    """

    def __init__(self, filename, _prefix=None, content_type=None):
        _prefix = self.get_path_from_prefix(_prefix)
        super(PageTemplate, self).__init__(filename, _prefix)
        if content_type is not None:
            self.content_type = content_type

    def pt_getContext(self, request, **kw):
        namespace = super(PageTemplate, self).pt_getContext(**kw)
        namespace['context'] = None
        namespace['request'] = request
        return namespace

    def __call__(self, request, **keywords):
        namespace = self.pt_getContext(
            request=request,
            options=keywords
            )
        return self.pt_render(namespace)

class PageTemplateResource(BrowserView, Resource):

    implements(IBrowserPublisher)

    def publishTraverse(self, request, name):
        '''See interface IBrowserPublisher'''
        raise NotFound(None, name)

    def browserDefault(self, request):
        '''See interface IBrowserPublisher'''
        return getattr(self, request.method), ()

    def HEAD(self):
        pt = self.context
        response = self.request.response
        if not response.getHeader("Content-Type"):
            response.setHeader("Content-Type", pt.content_type)
        return ''

    def GET(self):
        pt = self.context
        response = self.request.response
        if not response.getHeader("Content-Type"):
            response.setHeader("Content-Type", pt.content_type)
        return pt(self.request)

class PageTemplateResourceFactory(object):

    implements(IResourceFactory)
    classProvides(IResourceFactoryFactory)

    def __init__(self, path, checker, name):
        self.__pt = PageTemplate(path)
        self.__checker = checker
        self.__name = name

    def __call__(self, request):
        resource = PageTemplateResource(self.__pt, request)
        resource.__Security_checker__ = self.__checker
        resource.__name__ = self.__name
        return resource