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
8eb5e8d3
Commit
8eb5e8d3
authored
Aug 03, 2000
by
Chris McDonough
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merging ZCatalog keyerror fixes into trunk.
parent
af746749
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
19 deletions
+52
-19
lib/python/Products/ZCatalog/Catalog.py
lib/python/Products/ZCatalog/Catalog.py
+21
-5
lib/python/SearchIndex/UnIndex.py
lib/python/SearchIndex/UnIndex.py
+13
-3
lib/python/SearchIndex/UnKeywordIndex.py
lib/python/SearchIndex/UnKeywordIndex.py
+9
-4
lib/python/SearchIndex/UnTextIndex.py
lib/python/SearchIndex/UnTextIndex.py
+9
-7
No files found.
lib/python/Products/ZCatalog/Catalog.py
View file @
8eb5e8d3
...
...
@@ -96,6 +96,7 @@ from MultiMapping import MultiMapping
from
string
import
lower
import
Record
from
Missing
import
MV
from
zLOG
import
LOG
,
ERROR
from
Lazy
import
LazyMap
,
LazyFilter
,
LazyCat
...
...
@@ -174,6 +175,9 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
if
brains
is
not
None
:
self
.
_v_brains
=
brains
self
.
updateBrains
()
def
updateBrains
(
self
):
self
.
useBrains
(
self
.
_v_brains
)
def
__getitem__
(
self
,
index
,
ttype
=
type
(())):
...
...
@@ -200,7 +204,7 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
""" initialize your brains. This method is called when the
catalog is first activated (from the persistent storage) """
Persistent
.
__setstate__
(
self
,
state
)
self
.
u
seBrains
(
self
.
_v_brains
)
self
.
u
pdateBrains
(
)
if
not
hasattr
(
self
,
'lexicon'
):
self
.
lexicon
=
Lexicon
()
...
...
@@ -262,7 +266,7 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
self
.
schema
=
schema
# new column? update the brain
self
.
u
seBrains
(
self
.
_v_brains
)
self
.
u
pdateBrains
(
)
self
.
__changed__
(
1
)
#why?
...
...
@@ -274,6 +278,8 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
_index
=
names
.
index
(
name
)
if
not
self
.
schema
.
has_key
(
name
):
LOG
(
'Catalog'
,
ERROR
,
(
'delColumn attempted to delete '
'nonexistent column %s.'
%
str
(
name
)))
return
names
.
remove
(
name
)
...
...
@@ -288,7 +294,7 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
self
.
names
=
tuple
(
names
)
# update the brain
self
.
u
seBrains
(
self
.
_v_brains
)
self
.
u
pdateBrains
(
)
# remove the column value from each record
for
key
in
self
.
data
.
keys
():
...
...
@@ -372,6 +378,9 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
if
hasattr
(
x
,
'index_object'
):
blah
=
x
.
index_object
(
i
,
object
,
threshold
)
total
=
total
+
blah
else
:
LOG
(
'Catalog'
,
ERROR
,
(
'catalogObject was passed '
'bad index object %s.'
%
str
(
x
)))
self
.
data
=
data
...
...
@@ -405,9 +414,16 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
try
:
del
btree
[
rid
]
except
KeyError
:
pass
LOG
(
'Catalog'
,
ERROR
,
(
'uncatalogObject unsuccessfully '
'attempted to delete rid %s '
'from paths or data btree.'
%
rid
))
del
uids
[
uid
]
self
.
data
=
data
else
:
LOG
(
'Catalog'
,
ERROR
,
(
'uncatalogObject unsuccessfully '
'attempted to uncatalog an object '
'with a uid of %s. '
%
rid
))
def
clear
(
self
):
""" clear catalog """
...
...
lib/python/SearchIndex/UnIndex.py
View file @
8eb5e8d3
...
...
@@ -84,7 +84,7 @@
##############################################################################
"""Simple column indices"""
__version__
=
'$Revision: 1.1
2
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.1
3
$'
[
11
:
-
2
]
from
Globals
import
Persistent
from
Acquisition
import
Implicit
...
...
@@ -94,6 +94,7 @@ from intSet import intSet
import
operator
from
Missing
import
MV
import
string
,
pdb
from
zLOG
import
LOG
,
ERROR
ListType
=
type
([])
StringType
=
type
(
's'
)
...
...
@@ -193,11 +194,20 @@ class UnIndex(Persistent, Implicit):
k
=
unindex
.
get
(
i
,
None
)
if
k
is
None
:
LOG
(
'UnIndex'
,
ERROR
,
(
'unindex_object couldn
\
'
t unindex '
'document %s. This should not happen.'
%
str
(
i
)))
return
None
set
=
index
.
get
(
k
,
None
)
if
set
is
not
None
:
try
:
set
.
remove
(
i
)
except
:
pass
LOG
(
'UnIndex'
,
ERROR
,
(
'unindex_object tried to retrieve set %s'
'from index %s but couldn
\
'
t. This '
'should not happen.'
%
(
repr
(
set
),
str
(
k
))))
try
:
set
.
remove
(
i
)
except
:
LOG
(
'UnIndex'
,
ERROR
,
(
'unindex_object could not remove '
'integer id %s from index.'
%
str
(
k
)))
del
unindex
[
i
]
self
.
_index
=
index
...
...
lib/python/SearchIndex/UnKeywordIndex.py
View file @
8eb5e8d3
from
UnIndex
import
UnIndex
,
MV
,
intSet
from
types
import
ListType
,
TupleType
from
zLOG
import
LOG
,
ERROR
class
UnKeywordIndex
(
UnIndex
):
...
...
@@ -50,12 +51,16 @@ class UnKeywordIndex(UnIndex):
kws
=
unindex
.
get
(
i
,
None
)
if
kws
is
None
:
return
None
LOG
(
'UnKeywordIndex'
,
ERROR
,(
'unindex_object was called with bad '
'integer id'
%
str
(
i
)))
for
kw
in
kws
:
set
=
index
.
get
(
kw
,
None
)
if
set
is
not
None
:
set
.
remove
(
i
)
if
set
is
not
None
:
set
.
remove
(
i
)
else
:
LOG
(
'UnKeywordIndex'
,
ERROR
,
(
'unindex_object could not '
'remove %s from set'
%
str
(
i
)))
del
unindex
[
i
]
self
.
_index
=
index
...
...
lib/python/SearchIndex/UnTextIndex.py
View file @
8eb5e8d3
...
...
@@ -92,7 +92,7 @@ is no longer known.
"""
__version__
=
'$Revision: 1.2
4
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.2
5
$'
[
11
:
-
2
]
from
Globals
import
Persistent
import
BTree
,
IIBTree
,
IOBTree
,
OIBTree
...
...
@@ -106,7 +106,7 @@ import operator
from
Splitter
import
Splitter
from
string
import
strip
import
string
,
regex
,
regsub
,
ts_regex
from
zLOG
import
LOG
,
ERROR
from
Lexicon
import
Lexicon
,
stop_word_dict
...
...
@@ -299,7 +299,9 @@ class UnTextIndex(Persistent, Implicit):
index
[
word_id
]
=
r
unindex
[
i
].
append
(
word_id
)
else
:
r
[
i
]
=
score
else
:
r
[
i
]
=
score
unindex
[
i
].
append
(
word_id
)
else
:
index
[
word_id
]
=
i
,
score
unindex
[
i
].
append
(
word_id
)
...
...
@@ -314,7 +316,6 @@ class UnTextIndex(Persistent, Implicit):
## return the number of words you indexed
return
times
def
unindex_object
(
self
,
i
,
tt
=
type
(())
):
""" carefully unindex document with integer id 'i' from the text
index and do not fail if it does not exist """
...
...
@@ -330,11 +331,12 @@ class UnTextIndex(Persistent, Implicit):
try
:
del
index
[
n
][
i
]
except
(
KeyError
,
IndexError
,
TypeError
):
pass
LOG
(
'UnTextIndex'
,
PROBLEM
,
'unindex_object tried to unindex nonexistent'
' document %s'
%
str
(
i
))
del
unindex
[
i
]
self
.
_index
=
index
self
.
_unindex
=
unindex
def
__getitem__
(
self
,
word
):
"""Return an InvertedIndex-style result "list"
...
...
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