Commit d60ce904 authored by Martijn Pieters's avatar Martijn Pieters

Mark ZCatalog catalog brains with an interface

parent 20110cf2
......@@ -51,6 +51,9 @@ Zope Changes
Features added
- ZCatalog result objects (catalog brains) now have an interface,
ZCatalog.interfaces.ICatalogBrain.
- A new module, AccessControl.requestmethod, provides a decorator
factory that limits decorated methods to one request method only.
For example, marking a method with @requestmethod('POST') limits
......
......@@ -13,9 +13,13 @@
__version__ = "$Revision$"[11:-2]
from zope.interface import implements
import Acquisition, Record
from ZODB.POSException import ConflictError
from interfaces import ICatalogBrain
# Switch for new behavior, raise exception instead of returning None.
# Use 'catalog-getObject-raises off' in zope.conf to restore old behavior.
GETOBJECT_RAISES = True
......@@ -25,6 +29,8 @@ class AbstractCatalogBrain(Record.Record, Acquisition.Implicit):
required, and provides just enough smarts to let us get the URL, path,
and cataloged object without having to ask the catalog directly.
"""
implements(ICatalogBrain)
def has_key(self, key):
return self.__record_schema__.has_key(key)
......
......@@ -246,3 +246,37 @@ class IZCatalog(Interface):
pghandler -- optional Progresshandler as defined in ProgressHandler.py
(see also README.txt)
"""
# XXX This should inherit from an IRecord interface, if there ever is one.
class ICatalogBrain(Interface):
"""Catalog brain that handles looking up attributes as
required, and provides just enough smarts to let us get the URL, path,
and cataloged object without having to ask the catalog directly.
"""
def has_key(key):
"""Record has this field"""
def getPath():
"""Get the physical path for this record"""
def getURL(relative=0):
"""Generate a URL for this record"""
def _unrestrictedGetObject():
"""Return the object for this record
Same as getObject, but does not do security checks.
"""
def getObject():
"""Return the object for this record
Will return None if the object cannot be found via its cataloged path
(i.e., it was deleted or moved without recataloging), or if the user is
not authorized to access the object.
"""
def getRID():
"""Return the record ID for this object."""
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment