Re: [Zope-dev] Keyword Indexes causing Keyerrors

2000-12-21 Thread Itamar Shtull-Trauring

Here's what was causing my KeyErrors, and how I solved it, and why I think
KeywordIndexes broke. I have a keyword index on the "categories" property of
my CatalogAware object. "categories" is a list.

def manage_removeItems(self, ids=[]):
""" Remove listed items from this category """
for id in ids:
ob = getattr(self.Items, id)
categories = ob.categories # -- this is the problem
categories.remove(self.uid)
ob.manage_changeProperties(categories=categories)
ob.reindex_object()

I solved the problem by switching the problem line to say "categories =
ob.categories[:]".

What does this mean? I was mutating the same list that was attached to the
object. Doing this caused the Keyword Index to break. I assume the reason
then is that the index somewhere stored a reference to the "categories"
property, not a copy. This means that when I mutated ob.categories, I was
also mutating the contents of the index, causing it to get screwed up. The
solution would be that keyword indexes store a *copy* of the property they
are indexing, not a reference to it.

If I'm not mistaken, that means changing line 42 in UnKeywordIndex.py (2.2.4
version) from:

unindex[i] = kws

to:
unindex[i] = kws[:]

Although use of deepcopy may be a better idea?

-- 
Email: itamar(at)shtull-trauring.org
Web:   http://itamarst.org

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] Keyword Indexes causing Keyerrors

2000-12-20 Thread Christopher Petrilli

On 12/20/00 11:33 AM, "Itamar Shtull-Trauring" [EMAIL PROTECTED] wrote:

 I'm getting tons and tons of keyerrors when making changes to a catalogaware
 object's keyword index and then reindex_object() it. Alternatively, the
 Catalog doesn't get updated at all.  Is there any way to prevent this from
 happening, other than upgrading to 2.3?

Are you getting KeyErrors or are you getting log messages complaining about
keyts not existing?

Chris
-- 
| Christopher Petrilli Digital Creations
| [EMAIL PROTECTED]Where Zope comes from


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] Keyword Indexes causing Keyerrors

2000-12-20 Thread Christopher Petrilli

On 12/20/00 11:52 AM, "Itamar Shtull-Trauring" [EMAIL PROTECTED] wrote:

 KeyErrors - the logging says:
 2000-12-20T16:33:00 ERROR(200) UnKeywordIndex unindex_object could not
 remove 3 from set

This is not the "KeyError" in the sense that it's not propogated up to the
top level, but it is a lookup error lower down.  I will look into this, but
it seems to continue to work correctly, even with the log messages (these
are all due to trying to make sure things get unindexed correctly before
reindexing).  Are you getting incorrect data after reindexing the object?

Chris
-- 
| Christopher Petrilli Digital Creations
| [EMAIL PROTECTED]Where Zope comes from


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] keyword indexes

2000-12-15 Thread Steve Alexander

Josh Zeidner wrote:

 Hi,
 
   Currently I am wrestling with "keyword" indexes in ZCatalogs.  How do I
 query the ZCatalog for all records of objects indexed on a particular
 keyword.  For instance if my index is named MediaKeyword ive tried:
 
  dtml-in "Catalog.searchResults( MediaKeywords = ['ouch'] )"

That should work.

this has completely unpredictable results.
 
  dtml-in "Catalog.searchResults( MediaKeywords in ['ouch'] )"
 
this returns all indexed objects!

That won't work. The python

   MediaKeywords in ['ouch']

will be evaluated first, and will give a calue of 0 or 1. If 
MediaKeywords is a list, then it will always give 0, because there is 
only one item in ['ouch'], and that is the string 'ouch'.

   What am I doing wrong?  Is there a special ZCatalog function for querying
 keyword indexes?  I need some insight into this problem.

Are you sure that the keywords are being indexed in your catalog? A good 
trick is to index the keyword attribute, and also store it as metadata. 
That way, you can look through your search results at the keywords the 
Catalog thinks you have.

Also, check that you declared MediaKeywords as a keyword index, and that 
the MediaKeywords attribute in your objects is (or returns) a sequence 
type such as a tuple or a list.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] keyword indexes

2000-12-15 Thread Dieter Maurer

Josh Zeidner writes:
   dtml-in "Catalog.searchResults( MediaKeywords = ['ouch'] )"
This should work.
Alternatively: "MediaKeywords = 'ouch'".

   dtml-in "Catalog.searchResults( MediaKeywords in ['ouch'] )"
This calls the catalog without any keyword arguments
and with a single positional parameter 0.
The catalog interprets this as "no search criteria" and returns
all objects.


Dieter

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




[Zope-dev] keyword indexes

2000-12-14 Thread Josh Zeidner

Hi,

  Currently I am wrestling with "keyword" indexes in ZCatalogs.  How do I
query the ZCatalog for all records of objects indexed on a particular
keyword.  For instance if my index is named MediaKeyword ive tried:

 dtml-in "Catalog.searchResults( MediaKeywords = ['ouch'] )"

   this has completely unpredictable results.

 dtml-in "Catalog.searchResults( MediaKeywords in ['ouch'] )"

   this returns all indexed objects!

  What am I doing wrong?  Is there a special ZCatalog function for querying
keyword indexes?  I need some insight into this problem.

   Thanks!
Josh Zeidner


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )