Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
cb47ec84
Commit
cb47ec84
authored
Mar 11, 2002
by
Toby Dickenson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
merged toby-subclass-index-branch: Collector 284: KeywordIndex and FieldIndex subclassing
parent
69440268
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
17 deletions
+24
-17
lib/python/Products/PluginIndexes/KeywordIndex/KeywordIndex.py
...ython/Products/PluginIndexes/KeywordIndex/KeywordIndex.py
+9
-6
lib/python/Products/PluginIndexes/common/UnIndex.py
lib/python/Products/PluginIndexes/common/UnIndex.py
+15
-11
No files found.
lib/python/Products/PluginIndexes/KeywordIndex/KeywordIndex.py
View file @
cb47ec84
...
...
@@ -62,12 +62,7 @@ class KeywordIndex(UnIndex,PluggableIndex.PluggableIndex,Persistent,
# attribute we're interested in. If the attribute is callable,
# we'll do so.
newKeywords
=
getattr
(
obj
,
self
.
id
,
())
if
callable
(
newKeywords
):
newKeywords
=
newKeywords
()
if
type
(
newKeywords
)
is
StringType
:
newKeywords
=
(
newKeywords
,
)
newKeywords
=
self
.
_get_object_keywords
(
obj
)
oldKeywords
=
self
.
_unindex
.
get
(
documentId
,
None
)
...
...
@@ -96,6 +91,14 @@ class KeywordIndex(UnIndex,PluggableIndex.PluggableIndex,Persistent,
self
.
insertForwardIndexEntry
(
kw
,
documentId
)
return
1
def
_get_object_keywords
(
self
,
obj
):
newKeywords
=
getattr
(
obj
,
self
.
id
,
())
if
callable
(
newKeywords
):
newKeywords
=
newKeywords
()
if
hasattr
(
newKeywords
,
'capitalize'
):
# is it string-like ?
newKeywords
=
(
newKeywords
,
)
return
newKeywords
def
unindex_objectKeywords
(
self
,
documentId
,
keywords
):
""" carefully unindex the object with integer id 'documentId'"""
...
...
lib/python/Products/PluginIndexes/common/UnIndex.py
View file @
cb47ec84
...
...
@@ -13,7 +13,7 @@
"""Simple column indices"""
__version__
=
'$Revision: 1.
7
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
8
$'
[
11
:
-
2
]
from
Globals
import
Persistent
from
Acquisition
import
Implicit
...
...
@@ -216,16 +216,8 @@ class UnIndex(Persistent, Implicit):
returnStatus
=
0
# First we need to see if there's anything interesting to look at
# self.id is the name of the index, which is also the name of the
# attribute we're interested in. If the attribute is callable,
# we'll do so.
try
:
datum
=
getattr
(
obj
,
self
.
id
)
if
callable
(
datum
):
datum
=
datum
()
except
AttributeError
:
datum
=
_marker
datum
=
self
.
_get_object_datum
(
obj
)
# We don't want to do anything that we don't have to here, so we'll
# check to see if the new and existing information is the same.
oldDatum
=
self
.
_unindex
.
get
(
documentId
,
_marker
)
...
...
@@ -241,6 +233,18 @@ class UnIndex(Persistent, Implicit):
return
returnStatus
def
_get_object_datum
(
self
,
obj
):
# self.id is the name of the index, which is also the name of the
# attribute we're interested in. If the attribute is callable,
# we'll do so.
try
:
datum
=
getattr
(
obj
,
self
.
id
)
if
callable
(
datum
):
datum
=
datum
()
except
AttributeError
:
datum
=
_marker
return
datum
def
numObjects
(
self
):
""" return number of indexed objects """
return
len
(
self
.
_index
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment