##############################################################################
#
# 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.
#
##############################################################################
"""Key-reference interfaces
"""
import zope.interface
from zope.schema import DottedName
from zope.i18nmessageid import MessageFactory
_ = MessageFactory('zope')
[docs]class NotYet(Exception):
"""Can't compute a key reference for an object
It might be possible to compute one later
(e.g. at the end of the transaction).
"""
[docs]class IKeyReference(zope.interface.Interface):
"""A reference to an object (similar to a weak reference).
The references are compared by their hashes.
"""
key_type_id = DottedName(
title=_('Key Type Id'),
description=_('Key references should sort first '
'on their key type and second on any type-specific '
'information.')
)
def __call__():
"""Get the object this reference is linking to.
"""
def __hash__():
"""Get a unique identifier of the referenced object.
"""
def __eq__(ref):
"KeyReferences must be totally orderable."
def __lt__(ref):
"KeyReferences must be totally orderable."
def __ne__(ref):
"KeyReferences must be totally orderable."
def __gt__(ref):
"KeyReferences must be totally orderable."
def __le__(ref):
"KeyReferences must be totally orderable."
def __ge__(ref):
"KeyReferences must be totally orderable."