This file is indexed.

/usr/share/pyshared/zope/contentprovider/interfaces.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
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
##############################################################################
#
# 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.
#
##############################################################################
"""Content provider interfaces

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

import zope.component
import zope.interface
from zope.component.interfaces import ObjectEvent, IObjectEvent
from zope.publisher.interfaces import browser
from zope.tales import interfaces

class IUpdateNotCalled(zope.interface.common.interfaces.IRuntimeError):
    """Update Not Called

    An error that is raised when any content provider method is called before
    the ``update()`` method.
    """

class UpdateNotCalled(RuntimeError):
    pass

# Make it a singelton
UpdateNotCalled = UpdateNotCalled('``update()`` was not called yet.')

class IBeforeUpdateEvent(IObjectEvent):

    """A Contentprovider will be updated"""

    request = zope.interface.Attribute(
        """The request in which the object is udpated, might also be
        None""")

class BeforeUpdateEvent(ObjectEvent):

    """A Contentprovider will be updated"""

    zope.interface.implements(IBeforeUpdateEvent)

    def __init__(self, provider, request=None):
        super(BeforeUpdateEvent, self).__init__(provider)
        self.request = request

class IContentProvider(browser.IBrowserView):
    """A piece of content to be shown on a page.

    Objects implementing this interface are providing HTML content when they
    are rendered. It is up to the implementation to decide how to lookup
    necessary data to complete the job.

    Content Providers use a two-stage process to fulfill their contract:

    (1) The first stage is responsible to calculate the state of the content
        provider and, if applicable, edit the data. This stage is executed
        using the ``update()`` method.

    (2) During the second stage the provider constructs/renders its HTML
        output based on the state that was calculated in the first stage. This
        stage is executed using the ``render()`` method.

    Content Providers are discriminated by three components: the context, the
    request and the view. This allows great control over the selection of the
    provider.
    """

    __parent__ = zope.interface.Attribute(
        """The view the provider appears in.

        The view is the third discriminator of the content provider. It allows
        that the content can be controlled for different views.

        Having it stored as the parent is also very important for the security
        context to be kept.
        """)

    def update():
        """Initialize the content provider.

        This method should perform all state calculation and *not* refer it to
        the rendering stage.

        In this method, all state must be calculated from the current
        interaction (e.g., the browser request); all contained or managed
        content providers must have ``update()`` be called as well; any
        additional stateful API for contained or managed content providers
        must be handled; and persistent objects should be modified, if the
        provider is going to do it.

        Do *not* store state about persistent objects: the rendering process
        should actually use the persistent objects for the data, in case other
        components modify the object between the update and render stages.

        This method *must* be called before any other method that mutates the
        instance (besides the class constructor). Non-mutating methods and
        attributes may raise an error if used before ``update()`` is
        called. The view may rely on this order but is *not required* to
        explicitly enforce this. Implementations *may* enforce it as a
        developer aid.
        """

    def render(*args, **kw):
        """Return the content provided by this content provider.

        Calling this method before ``update()`` *may* (but is not required to)
        raise an ``UpdateNotCalled`` error.
        """

class IContentProviderType(zope.interface.interfaces.IInterface):
    """Type interface for content provider types (interfaces derived from
       IContentProvider).
    """


class ITALNamespaceData(zope.interface.interfaces.IInterface):
    """A type interface that marks an interface as a TAL data specification.

    All fields specified in an interface that provides `ITALNamespaceData`
    will be looked up in the TAL context and stored on the content provider. A
    content provider can have multiple interfaces that are of this type.
    """


class ContentProviderLookupError(zope.component.ComponentLookupError):
    """No content provider was found."""


class ITALESProviderExpression(interfaces.ITALESExpression):
    """Return the HTML content of the named provider.

    To call a content provider in a view use the the following syntax in a page
    template::

      <tal:block replace="structure provider:provider.name">

    The content provider is looked up by the (context, request, view) objects
    and the name (`provider.name`).
    """