## ## interfaces.py ## Login : ## Started on Sat May 28 13:36:51 2011 Uli Fouquet ## $Id$ ## ## Copyright (C) 2011 Uli Fouquet ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 2 of the License, or ## (at your option) any later version. ## ## This program 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 General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ## """ Interfaces for :mod:`waeup.sirp.index`. """ from zope.index.interfaces import IInjection from zope.catalog.field import IFieldIndex class IUnique(IInjection): def index_doc(docid, value): """Add a document to the index. `docid`: int, identifying the document `value`: the value to be indexed return: None This can also be used to reindex documents. If the same value is already stored under a different `docid`, a :exc:`KeyError` is raised. """ class IUniqueFieldIndex(IFieldIndex): """A field index that only accepts unique values. """ def index_doc(docid, value): """Index `value` under the given `docid`. Raises :exc:`KeyError` if the value is already stored for a different docid (unique-constraint violation). """ pass