Modified handling of 'catalog_name' parameter to allow function to use a catalog as well as a catalog name
authorThierry Florac <tflorac@ulthar.net>
Tue, 29 Sep 2009 22:35:14 +0200
changeset 21 d18c6cb028a8
parent 20 0efe926cbc3f
child 22 941b8c5eb563
Modified handling of 'catalog_name' parameter to allow function to use a catalog as well as a catalog name
ztfy/utils/catalog.py
--- a/ztfy/utils/catalog.py	Mon Sep 14 23:47:12 2009 +0200
+++ b/ztfy/utils/catalog.py	Tue Sep 29 22:35:14 2009 +0200
@@ -86,7 +86,10 @@
         request = request_utils.getRequest()
     intids = getIntIdUtility('', request, context)
     if intids is not None:
-        catalog = queryCatalog(catalog_name, context)
+        if ICatalog.providedBy(catalog_name):
+            catalog = catalog_name
+        else:
+            catalog = queryCatalog(catalog_name, context)
         if catalog is not None:
             id = intids.register(object)
             if index_name:
@@ -103,7 +106,10 @@
         request = request_utils.getRequest()
     id = getObjectId(object, '', request, context)
     if id is not None:
-        catalog = queryCatalog(catalog_name, context)
+        if ICatalog.providedBy(catalog_name):
+            catalog = catalog_name
+        else:
+            catalog = queryCatalog(catalog_name, context)
         if catalog is not None:
             if index_name:
                 catalog[index_name].unindex_doc(id)