This file is indexed.

/usr/share/pyshared/zope/contentprovider/tales.py is in python-zope.contentprovider 3.7.2-0ubuntu4.

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) 2004 Zope Foundation 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.
#
##############################################################################
"""Provider TALES expression

$Id: tales.py 112004 2010-05-05 17:54:28Z tseaver $
"""
__docformat__ = 'restructuredtext'

import zope.component
import zope.interface
import zope.schema
import zope.event
from zope.location.interfaces import ILocation
from zope.tales import expressions

from zope.contentprovider import interfaces

def addTALNamespaceData(provider, context):
    """Add the requested TAL attributes to the provider"""
    data = {}

    for interface in zope.interface.providedBy(provider):
        if interfaces.ITALNamespaceData.providedBy(interface):
            for name, field in zope.schema.getFields(interface).items():
                data[name] = context.vars.get(name, field.default)

    provider.__dict__.update(data)


class TALESProviderExpression(expressions.StringExpr):
    """Collect content provider via a TAL namespace.

    Note that this implementation of the TALES `provider` namespace does not
    work with interdependent content providers, since each content-provider's
    stage one call is made just before the second stage is executed. If you
    want to implement interdependent content providers, you need to consider a
    TAL-independent view implementation that will complete all content
    providers' stage one before rendering any of them.
    """

    zope.interface.implements(interfaces.ITALESProviderExpression)

    def __call__(self, econtext):
        name = super(TALESProviderExpression, self).__call__(econtext)
        context = econtext.vars['context']
        request = econtext.vars['request']
        view = econtext.vars['view']

        # Try to look up the provider.
        provider = zope.component.queryMultiAdapter(
            (context, request, view), interfaces.IContentProvider, name)

        # Provide a useful error message, if the provider was not found.
        if provider is None:
            raise interfaces.ContentProviderLookupError(name)

        # add the __name__ attribute if it implements ILocation
        if ILocation.providedBy(provider):
            provider.__name__ = name

        # Insert the data gotten from the context
        addTALNamespaceData(provider, econtext)

        # Stage 1: Do the state update.
        zope.event.notify(interfaces.BeforeUpdateEvent(provider, request))
        provider.update()

        # Stage 2: Render the HTML content.
        return provider.render()