/usr/lib/python2.7/dist-packages/storm/zope/interfaces.py is in python-storm 0.19-2.
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 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | #
# Copyright (c) 2006, 2007 Canonical
#
# Written by Gustavo Niemeyer <gustavo@niemeyer.net>
#
# This file is part of Storm Object Relational Mapper.
#
# Storm is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2.1 of
# the License, or (at your option) any later version.
#
# Storm is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from zope.interface import Interface
from storm.expr import Undef
class ZStormError(Exception):
"""
Raised when situations such as duplicate store creation, unknown
store name, etc., arise.
"""
class IZStorm(Interface):
"""A flag interface used to lookup the ZStorm utility."""
class IResultSet(Interface):
"""The interface for a L{ResultSet}.
The rationale behind the exposed attributes is:
1. Model code constructs a L{ResultSet} and returns a security proxied
object to the view code.
2. View code treats the L{ResultSet} as an immutable sequence/iterable
and presents the data to the user.
Therefore several attributes of L{ResultSet} are not included here:
- Both C{set()} and C{remove()} can be used to modify the contained
objects, which will bypass the security proxies on those objects.
- C{get_select_expr()} will return a L{Select} object, which has no
security declarations (and it isn't clear that any would be
desirable).
- C{find()}, C{group_by()} and C{having()} are really used to configure
result sets, so are mostly intended for use on the model side.
- There may be an argument for exposing C{difference()},
C{intersection()} and C{union()} as a way for view code to combine
multiple results, but it isn't clear how often it makes sense to do
this on the view side rather than model side.
"""
def copy():
"""
Return a copy of this result set object, with the same configuration.
"""
def config(distinct=None, offset=None, limit=None):
"""Configure the result set.
@param distinct: Optionally, when true, only return distinct rows.
@param offset: Optionally, the offset to start retrieving
records from.
@param limit: Optionally, the maximum number of rows to return.
"""
def __iter__():
"""Iterate the result set."""
def __getitem__(index):
"""
Get the value at C{index} in the result set if C{index} is a
single interger. If C{index} is a slice a new C{ResultSet}
will be returned.
"""
def __contains__(item):
"""Check if C{item} is contained in the result set."""
def any():
"""
Get a random object from the result set or C{None} if the
result set is empty.
"""
def first():
"""Return the first item from an ordered result set.
@raises UnorderedError: Raised if the result set isn't ordered.
"""
def last():
"""Return the last item from an ordered result set.
@raises UnorderedError: Raised if the result set isn't ordered.
"""
def one():
"""
Return one item from a result set containing at most one item
or None if the result set is empty.
@raises NotOneError: Raised if the result set contains more
than one item.
"""
def order_by(*args):
"""Order the result set based on expressions in C{args}."""
def count(column=Undef, distinct=False):
"""Returns the number of rows in the result set.
@param column: Optionally, the column to count.
@param distinct: Optionally, when true, count only distinct rows.
"""
def max(column):
"""Returns the maximum C{column} value in the result set."""
def min():
"""Returns the minimum C{column} value in the result set."""
def avg():
"""Returns the average of C{column} values in the result set."""
def sum():
"""Returns the sum of C{column} values in the result set."""
def values(*args):
"""Generator yields values for the columns specified in C{args}."""
def cached():
"""Return matching objects from the cache for the current query."""
def is_empty():
"""Return true if the result set contains no results."""
class ISQLObjectResultSet(Interface):
def __getitem__(item):
"""List emulation."""
def __getslice__(slice):
"""Slice support."""
def __iter__():
"""List emulation."""
def count():
"""Return the number of items in the result set."""
def __nonzero__():
"""Return C{True} if this result set contains any results.
@note: This method is provided for compatibility with SQL Object. For
new code, prefer L{is_empty}. It's compatible with L{ResultSet}
which doesn't have a C{__nonzero__} implementation.
"""
def __contains__(item):
"""Support C{if FooObject in Foo.select(query)}."""
def intersect(otherSelect, intersectAll=False, orderBy=None):
"""Return the intersection of this result and C{otherSelect}
@param otherSelect: the other L{ISQLObjectResultSet}
@param intersectAll: whether to use INTERSECT ALL behaviour
@param orderBy: the order the result set should use.
"""
def is_empty():
"""Return C{True} if this result set doesn't contain any results."""
def prejoin(prejoins):
"""Return a new L{SelectResults} with the list of attributes prejoined.
@param prejoins: The list of attribute names to prejoin.
"""
|