[Grok-dev] Demo of Kirbi online

Luciano Ramalho luciano at ramalho.org
Sun Jul 8 22:34:08 EDT 2007


There's not a whole lot to see, but I put a demo of Kirbi running on
Paleosoft.org:

http://paleosoft.org:8080/kirbi/pac/?query=zope

There are 289 books in the demo. Searches can be made using words in
the title or authors. In the book details page, the authors are
clickable to perform author searches.

I wanted to make the author search use a set index to search for the
precise name of the author, but could not make it work. I set up a pdb
trace inside the book.creatorsSet method and discovered it is never
invoked, but book.searchableText is working fine...

If anyone would like to review, below are the relevant parts of the code [1].

BTW, is there an easy way to look into the catalog to see the contents
of the indexes, like we can in Zope 2?

Cheers,

Luciano

[1] http://svn.zope.org/Sandbox/luciano/kirbi/src/kirbi/

#############################
# Index declarations in app.py:
#############################

class BookIndexes(grok.Indexes):
    grok.site(Kirbi)
    grok.context(Book)

    title = index.Text()
    isbn13 = index.Field()
    searchableText = index.Text()

    #XXX: this is not working: the creatorSet book method is never called
    creatorsSet = index.Set()

#############################
# creatorsSet method in book.py
#############################

class Book(grok.Model):
    # [ lots of code snipped ]

    def creatorsSet(self):
        #XXX: this is never invoked so the creatorSet index in app.py is not
        # being pupulated
        creators = set()
        for creator in self.creators():
            if '(' in creator: # remove role string
                creator = creator.split('(')[0]
            creators.add(creator.strip().lower())
        import pdb; pdb.set_trace()
        return list(creators)

    def searchableText(self):
        #XXX this however is working fine... so why isn't creatorsSet?
        return self.title + ' ' + ' '.join(self.creators)


More information about the Grok-dev mailing list