[Grok-dev] Indexes not updated on object modification

Àlex Magaz Graça rivaldi8 at gmail.com
Wed Dec 7 18:47:00 UTC 2011


I'm getting indexes updated on object creation but not when they are 
modified, unless I call ICatalog.updateIndexes(). Shouldn't the catalog 
be notified about modifications and update affected indexes?

This is more or less what I have:

class Helpdesk(grok.Application, grok.Container):
     def __init__(self):
         super(Helpdesk, self).__init__()
         self["tickets"] = TicketCatalog()

class TicketCatalog(grok.Container):

class Ticket(grok.Model):
     def __init__(self, reporter):
         super(Ticket, self).__init__()
         self.reporter = reporter

class TicketIndex(grok.Indexes):

     reporter = grok.index.Field()

After adding an object I get it from searchResults:

ticket1 = Ticket("foo")
context["1"] = ticket1
catalog = getUtility(ICatalog)
results = catalog.searchResults( reporter=("bar", "bar") )
(results empty)

here "context" would be an instance of TicketCatalog. However, if later I
decide to modify the stored object, the index is not updated and 
still gives me the same results:

ticket1.reporter = "bar"
catalog = getUtility(ICatalog)
results = catalog.searchResults( reporter=("bar", "bar") )
(results empty again)

results = catalog.searchResults( reporter=("bar", "bar") )
(I get the ticket)

Is there anything wrong?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.zope.org/pipermail/grok-dev/attachments/20111207/77caadf8/attachment.html>

More information about the Grok-dev mailing list