source: main/waeup.sirp/branches/unique-index/interfaces.py @ 11107

Last change on this file since 11107 was 6555, checked in by uli, 13 years ago

Remove the pass statement, because coverage detect says it is not
executed. A lie and the whole action is pathetic, I know, but it looks
better in coverage statistics to have the green 100% field.

File size: 1.7 KB
Line 
1##
2## interfaces.py
3## Login : <uli@pu.smp.net>
4## Started on  Sat May 28 13:36:51 2011 Uli Fouquet
5## $Id$
6##
7## Copyright (C) 2011 Uli Fouquet
8## This program is free software; you can redistribute it and/or modify
9## it under the terms of the GNU General Public License as published by
10## the Free Software Foundation; either version 2 of the License, or
11## (at your option) any later version.
12##
13## This program is distributed in the hope that it will be useful,
14## but WITHOUT ANY WARRANTY; without even the implied warranty of
15## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16## GNU General Public License for more details.
17##
18## You should have received a copy of the GNU General Public License
19## along with this program; if not, write to the Free Software
20## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21##
22"""
23Interfaces for :mod:`waeup.sirp.index`.
24"""
25from zope.index.interfaces import IInjection
26from zope.catalog.field import IFieldIndex
27
28class IUnique(IInjection):
29    def index_doc(docid, value):
30        """Add a document to the index.
31
32        `docid`: int, identifying the document
33
34        `value`: the value to be indexed
35
36        return: None
37
38        This can also be used to reindex documents.
39
40        If the same value is already stored under a different `docid`,
41        a :exc:`KeyError` is raised.
42        """
43
44
45class IUniqueFieldIndex(IFieldIndex):
46    """A field index that only accepts unique values.
47    """
48
49    def index_doc(docid, value):
50        """Index `value` under the given `docid`.
51
52        Raises :exc:`KeyError` if the value is already stored for a
53        different docid (unique-constraint violation).
54        """
Note: See TracBrowser for help on using the repository browser.