[Zope-dev] Zope Tests: 5 OK

2007-07-23 Thread Zope Tests Summarizer
Summary of messages to the zope-tests list.
Period Sun Jul 22 12:00:00 2007 UTC to Mon Jul 23 12:00:00 2007 UTC.
There were 5 messages: 5 from Zope Unit Tests.


Tests passed OK
---

Subject: OK : Zope-2.7 Python-2.3.6 : Linux
From: Zope Unit Tests
Date: Sun Jul 22 20:52:51 EDT 2007
URL: http://mail.zope.org/pipermail/zope-tests/2007-July/008072.html

Subject: OK : Zope-2.8 Python-2.3.6 : Linux
From: Zope Unit Tests
Date: Sun Jul 22 20:54:23 EDT 2007
URL: http://mail.zope.org/pipermail/zope-tests/2007-July/008073.html

Subject: OK : Zope-2.9 Python-2.4.4 : Linux
From: Zope Unit Tests
Date: Sun Jul 22 20:55:53 EDT 2007
URL: http://mail.zope.org/pipermail/zope-tests/2007-July/008074.html

Subject: OK : Zope-2.10 Python-2.4.4 : Linux
From: Zope Unit Tests
Date: Sun Jul 22 20:57:25 EDT 2007
URL: http://mail.zope.org/pipermail/zope-tests/2007-July/008075.html

Subject: OK : Zope-trunk Python-2.4.4 : Linux
From: Zope Unit Tests
Date: Sun Jul 22 20:58:56 EDT 2007
URL: http://mail.zope.org/pipermail/zope-tests/2007-July/008076.html

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


[Zope-dev] Re: possible bug in Catalog.py with keyword index ?

2007-07-23 Thread Joachim Schmitz

Dieter Maurer schrieb:

Joachim Schmitz wrote at 2007-7-20 10:40 +0200:

Obviously, you got the wrong mainling list.

This is not a ZODB problem...


my mistake it should have gone to the zope-dev list.

...
I found in Catalog.py updateMetadata around line 306

else:
if data.get(index, 0) != newDataRecord:
data[index] = newDataRecord

the if condition evaluates always to false, cause the data.get(index,0) 
accesses the data of the index and not of the metadata field as long as 
Zope was not restarted that worked fine.


The code above should prevent a write (which would grow the storage)
when in fact nothing changed. And it looks correct.

Yes, but it does not work as exspected.
Here is a more detailed description of our usecase:

In our catalog we have a keyword index "registered_courses" and a 
metadata field "registered_courses". If a student registers a new course 
an event is triggered, which adds the new course to the index.  In our 
event-handler we have:



  res = students_catalog(id = student_id)
  if not res:
  return
  student_rec = res[0]
  registered_courses = getattr(student_rec,'registered_courses',None)
  if not registered_courses:
  registered_courses = []
  #import pdb;pdb.set_trace()
  if event_type == "sys_add_object":
  if course_id not in registered_courses:
  registered_courses.append(course_id)
  else:
  return
  elif registered_courses and event_type == "sys_del_object":
  removed = False
  while course_id in registered_courses:
   removed = True
   registered_courses.remove(course_id)
  if not removed:
   return
  record_data = {}
  for field in self.schema() + self.indexes():
  record_data[field] = getattr(student_rec, field)
  # Add the updated data:
  record_data.update(data)
  self.catalog_object(dict2ob(record_data), student_id)

where dict2obj does just that.

That updates the meta_data only on index_creation, and after a zope 
restart the meta_data for registered_courses only contained the first 
added course. That was because (i asume)


data.get(index, 0) always got the data from the index, and not from the 
meta_data. I could veryfy this by looking at the catalog-record in the 
ZMI. So it neve got to update the meta_data, so the "real" cause for 
this problem is that data.get(index, 0), returns the value of the index 
here and not that of the meta_data.








--
Gruß Joachim

___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope )