[z3-checkins] r5798 - z3/Flon/trunk/tools

dreamcatcher at codespeak.net dreamcatcher at codespeak.net
Thu Jul 29 22:18:08 MEST 2004


Author: dreamcatcher
Date: Thu Jul 29 22:18:07 2004
New Revision: 5798

Added:
   z3/Flon/trunk/tools/catalog.py   (contents, props changed)
Log:
Forgot to add this file.

Added: z3/Flon/trunk/tools/catalog.py
==============================================================================
--- (empty file)
+++ z3/Flon/trunk/tools/catalog.py	Thu Jul 29 22:18:07 2004
@@ -0,0 +1,51 @@
+# Flon is a package for enabling hand picked Five features in Plone
+# Copyright (C) 2004 Enfold Systems, LLC
+#
+# 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
+#
+"""
+$Id: __init__.py,v 1.2 2004/07/14 22:23:16 dreamcatcher Exp $
+"""
+
+from AccessControl import ClassSecurityInfo
+from AccessControl.Permissions import manage_zcatalog_entries
+from Products.CMFPlone.CatalogTool import CatalogTool
+
+_marker = []
+
+class TraversableObjectWrapper:
+
+    def __init__(self, ob):
+        self.__ob = ob
+
+    def __getattr__(self, name):
+        value = self.__ob.unrestrictedTraverse(name, _marker)
+        if value is not _marker:
+            return value
+        return getattr(self.__ob, name)
+
+def catalog_object(self, obj, uid=None, idxs=[]):
+    """Patched to allow intercepting catalog requests for attributes
+    hook Five traversal to allow indexing results of views.
+    """
+    obj = TraversableObjectWrapper(obj)
+    return self._flon_catalog_object(obj, uid, idxs)
+
+if not hasattr(CatalogTool, '_flon_catalog_object'):
+    CatalogTool._flon_catalog_object = CatalogTool.catalog_object
+    CatalogTool.catalog_object = catalog_object
+    security = getattr(CatalogTool, 'security', ClassSecurityInfo())
+    security.declareProtected(manage_zcatalog_entries, 'catalog_object')
+    security.apply(CatalogTool)


More information about the z3-checkins mailing list