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
e299a8a0
Commit
e299a8a0
authored
Feb 02, 2003
by
Andreas Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ZCTextIndex is now able to index more than one attribute of an object
parent
3c22794e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
14 deletions
+31
-14
doc/CHANGES.txt
doc/CHANGES.txt
+1
-1
lib/python/Products/ZCTextIndex/ZCTextIndex.py
lib/python/Products/ZCTextIndex/ZCTextIndex.py
+26
-10
lib/python/Products/ZCTextIndex/dtml/addZCTextIndex.dtml
lib/python/Products/ZCTextIndex/dtml/addZCTextIndex.dtml
+2
-1
lib/python/Products/ZCTextIndex/dtml/manageZCTextIndex.dtml
lib/python/Products/ZCTextIndex/dtml/manageZCTextIndex.dtml
+2
-2
No files found.
doc/CHANGES.txt
View file @
e299a8a0
...
...
@@ -29,7 +29,7 @@ Zope Changes
enforce this behaviour inside the ZPublisher. See also
doc/ENVIRONMENT.txt to check with the DATETIME_FORMAT
- KeywordIndex
and FieldIndex are now cap
able to index more
- KeywordIndex
, FieldIndex and ZCTextIndex are now
able to index more
than one attribute of an object. This removes the ties between the
indexes ID and the attribute name to be indexed.
...
...
lib/python/Products/ZCTextIndex/ZCTextIndex.py
View file @
e299a8a0
...
...
@@ -67,9 +67,9 @@ class ZCTextIndex(Persistent, Acquisition.Implicit, SimpleItem):
field_name
=
None
,
lexicon_id
=
None
):
self
.
id
=
id
#
Arguments can be passed directly to the constructor or
# via the silly "extra" record.
self
.
_
fieldname
=
field_name
or
getattr
(
extra
,
'doc_attr'
,
''
)
or
id
#
indexed attributes
self
.
_indexed_attrs
=
getattr
(
extra
,
'doc_attr'
,
''
).
split
(
','
)
or
[
field_name
]
or
[
id
]
self
.
_
indexed_attrs
=
[
attr
.
strip
()
for
attr
in
self
.
_indexed_attrs
if
attr
]
lexicon_id
=
lexicon_id
or
extra
.
lexicon_id
lexicon
=
getattr
(
caller
,
lexicon_id
,
None
)
...
...
@@ -96,6 +96,9 @@ class ZCTextIndex(Persistent, Acquisition.Implicit, SimpleItem):
self
.
index
=
self
.
_index_factory
(
aq_base
(
self
.
getLexicon
()))
## Private Methods ##
security
.
declarePrivate
(
'getLexicon'
)
...
...
@@ -148,9 +151,22 @@ class ZCTextIndex(Persistent, Acquisition.Implicit, SimpleItem):
## Pluggable Index APIs ##
def
index_object
(
self
,
docid
,
obj
,
threshold
=
None
):
def
index_object
(
self
,
documentId
,
obj
,
threshold
=
None
):
""" wrapper to handle indexing of multiple attributes """
# needed for backward compatibility
try
:
fields
=
self
.
_indexed_attrs
except
:
fields
=
[
self
.
_fieldname
]
res
=
0
for
attr
in
fields
:
res
+=
self
.
_index_object
(
documentId
,
obj
,
threshold
,
attr
)
return
res
>
0
def
_index_object
(
self
,
docid
,
obj
,
threshold
=
None
,
attr
=
""
):
# XXX We currently ignore subtransaction threshold
text
=
getattr
(
obj
,
self
.
_fieldname
,
None
)
text
=
getattr
(
obj
,
attr
,
None
)
if
text
is
None
:
return
0
if
callable
(
text
):
...
...
@@ -181,7 +197,7 @@ class ZCTextIndex(Persistent, Acquisition.Implicit, SimpleItem):
return
None
tree
=
QueryParser
(
self
.
getLexicon
()).
parseQuery
(
query_str
)
results
=
tree
.
executeQuery
(
self
.
index
)
return
results
,
(
self
.
_fieldname
,)
return
results
,
(
self
.
id
,)
def
getEntryForObject
(
self
,
documentId
,
default
=
None
):
"""Return the list of words indexed for documentId"""
...
...
@@ -217,15 +233,15 @@ class ZCTextIndex(Persistent, Acquisition.Implicit, SimpleItem):
def
getIndexSourceNames
(
self
):
"""Return sequence of names of indexed attributes"""
return
[
self
.
_fieldname
]
try
:
return
self
.
_indexed_attrs
except
:
return
[
self
.
_fieldname
]
def
getIndexType
(
self
):
"""Return index type string"""
return
getattr
(
self
,
'_index_type'
,
self
.
_index_factory
.
__name__
)
def
getFieldName
(
self
):
"""Return indexed attribute name"""
return
self
.
_fieldname
def
getLexiconURL
(
self
):
"""Return the url of the lexicon used by the index"""
...
...
lib/python/Products/ZCTextIndex/dtml/addZCTextIndex.dtml
View file @
e299a8a0
...
...
@@ -32,10 +32,11 @@ from the most relevant to the least relevant.
<tr>
<td align="left" valign="top">
<div class="form-label">
Field name
Indexed attributes
</div></td>
<td align="left" valign="top">
<input type="text" name="extra.doc_attr:record" size="40" />
<em>attribute1,attribute2,...</em> or leave empty
</td>
</tr>
...
...
lib/python/Products/ZCTextIndex/dtml/manageZCTextIndex.dtml
View file @
e299a8a0
...
...
@@ -2,8 +2,8 @@
<dtml-var manage_tabs>
<p class="form-help">
Name
of attribute
indexed:
<em>
&dtml-getFieldName;
</em>
Name
(s) of attribute(s)
indexed:
<em>
<dtml-var "', '.join(getIndexSourceNames())">
</em>
</p>
<p class="form-help">
Index type:
...
...
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