[Zope-Checkins] SVN: Zope/trunk/ Mark ZCatalog catalog brains with
an interface
Martijn Pieters
mj at zopatista.com
Tue Mar 27 10:36:40 EDT 2007
Log message for revision 73762:
Mark ZCatalog catalog brains with an interface
Changed:
U Zope/trunk/doc/CHANGES.txt
U Zope/trunk/lib/python/Products/ZCatalog/CatalogBrains.py
U Zope/trunk/lib/python/Products/ZCatalog/interfaces.py
-=-
Modified: Zope/trunk/doc/CHANGES.txt
===================================================================
--- Zope/trunk/doc/CHANGES.txt 2007-03-27 14:34:19 UTC (rev 73761)
+++ Zope/trunk/doc/CHANGES.txt 2007-03-27 14:36:38 UTC (rev 73762)
@@ -51,6 +51,9 @@
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
Modified: Zope/trunk/lib/python/Products/ZCatalog/CatalogBrains.py
===================================================================
--- Zope/trunk/lib/python/Products/ZCatalog/CatalogBrains.py 2007-03-27 14:34:19 UTC (rev 73761)
+++ Zope/trunk/lib/python/Products/ZCatalog/CatalogBrains.py 2007-03-27 14:36:38 UTC (rev 73762)
@@ -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 @@
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)
Modified: Zope/trunk/lib/python/Products/ZCatalog/interfaces.py
===================================================================
--- Zope/trunk/lib/python/Products/ZCatalog/interfaces.py 2007-03-27 14:34:19 UTC (rev 73761)
+++ Zope/trunk/lib/python/Products/ZCatalog/interfaces.py 2007-03-27 14:36:38 UTC (rev 73762)
@@ -246,3 +246,37 @@
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."""
+
More information about the Zope-Checkins
mailing list