[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/common - UnIndex.py:1.14.6.1 __init__.py:1.3.138.1
Sidnei da Silva
sidnei@x3ng.com.br
Tue, 17 Jun 2003 14:14:58 -0400
Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/common
In directory cvs.zope.org:/tmp/cvs-serv10045/lib/python/Products/PluginIndexes/common
Modified Files:
Tag: Zope-2_6-branch
UnIndex.py __init__.py
Log Message:
- Made all PluginIndexes and ZCTextIndex use 'safe_callable',
which is aware of extension classes that fill 'tp_callable'
but don't define '__call__'.
- Made KeywordIndex be more robust about receiving a value that
is not a string or an iterable type.
=== Zope/lib/python/Products/PluginIndexes/common/UnIndex.py 1.14 => 1.14.6.1 ===
--- Zope/lib/python/Products/PluginIndexes/common/UnIndex.py:1.14 Wed Aug 14 18:19:34 2002
+++ Zope/lib/python/Products/PluginIndexes/common/UnIndex.py Tue Jun 17 14:14:28 2003
@@ -15,12 +15,15 @@
__version__='$Revision$'[11:-2]
+import sys
+from cgi import escape
+from types import StringType, ListType, IntType, TupleType
+
from Globals import Persistent
from Acquisition import Implicit
import BTree
import IOBTree
from zLOG import LOG, ERROR
-from types import StringType, ListType, IntType, TupleType
from BTrees.OOBTree import OOBTree, OOSet
from BTrees.IOBTree import IOBTree
@@ -29,8 +32,8 @@
import BTrees.Length
from Products.PluginIndexes.common.util import parseIndexRequest
-import sys
-from cgi import escape
+from Products.PluginIndexes.common import safe_callable
+
_marker = []
@@ -250,7 +253,7 @@
# we'll do so.
try:
datum = getattr(obj, self.id)
- if callable(datum):
+ if safe_callable(datum):
datum = datum()
except AttributeError:
datum = _marker
=== Zope/lib/python/Products/PluginIndexes/common/__init__.py 1.3 => 1.3.138.1 ===
--- Zope/lib/python/Products/PluginIndexes/common/__init__.py:1.3 Fri Jun 22 16:56:17 2001
+++ Zope/lib/python/Products/PluginIndexes/common/__init__.py Tue Jun 17 14:14:28 2003
@@ -1 +1,28 @@
-# empty comment for winzip and friends
+##############################################################################
+#
+# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (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
+#
+#############################################################################
+
+# This code is duplicated here from Products/ZCatalog/Catalog.py to avoid a
+# unnecessary dependency on ZCatalog.
+
+try:
+ from DocumentTemplate.cDocumentTemplate import safe_callable
+except ImportError:
+ def safe_callable(ob):
+ # Works with ExtensionClasses and Acquisition.
+ if hasattr(ob, '__class__'):
+ if hasattr(ob, '__call__'):
+ return 1
+ else:
+ return isinstance(ob, types.ClassType)
+ else:
+ return callable(ob)