Personal tools
You are here: Home Members kedai's Home TopicIndex and my first Zope diff
« March 2018 »
Sun Mon Tue Wed Thu Fri Sat
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Log in

Forgot your password?
Who - kedai (a) kedai . com . my
Where - Malaysia
What - we do zope/plone, linux solution for network, vpn, mail, etc
Document Actions

TopicIndex and my first Zope diff

by kedai last modified Nov. 21, 03 11:37 AM

I played around with TopicIndex these couple of days, and in the process submitted my first Zope diff file. ain;t that exciting, or what? ;)

But first off, what the heck is TopicIndex? There's little documentation available. There's the wiki and a README.txt in the directory.

From the readme, it looked to me that TopicIndex is a canned query to the catalog. Say we have an object that have two fields indexed (e.g section and bodytext). Normally, in a News page, we'd want to have a link to sections. The link will then points to a page with a list of news titles. This can be done like so:

#Script python
#no binding whatsoever
#called by zpt/dtml, iterate and call object.metadata
###parameter section
return context.Catalog(query={'section':section})

With TopicIndex, we can actually make this a canned query. I'm not sure whether the results are cached or what, but the README.txt says it should be faster.

Here's how to do it:

  1. go to Catalog. click Indexes.
  2. add TopicIndex (from the drop down add list). i'll call it topicSection for easier reference in this writeup
  3. click topicSection. add a FilteredSet. since i have 3 sections in my site (Linux, Zope, Others), i'll call this linuxCanned

    now add this in the Expression field:

    and click add. Note that the "" is important.

  4. repeat the steps for other sections; zopeCanned, othersCanned
    1. we're done. now we need to call it. we'll do that from Script (Python)

      #will be called from zpt/dtml, iterate and display object.metadata
      #section  to call
      return context.Catalog(query={'topicSection':'linuxCanned'})

      That's it. Minimal test were done with about 2000+ objects in catalogs, and the difference i see is about .1s Not sure whether the time improves with more objects in catalog. Probably will.

      And how is this related to my first Zope diff? Well typo, mostly. The manage* forms calls it filterId, but calls it filter_id. Not much of diff, but what the heck, right? ;)

      Please, if you have suggestions or better ways to use TopicIndex, please do say so.

      Have a great weekend!

alas .. it was not to be

Posted by kedai at Nov. 21, 03 10:36 PM

:) i did the changes in all dtml files first, but thought better changing it to the original, ie using fieldId.

anyways, feels good.

Powered by Plone, the Open Source Content Management System

This site conforms to the following standards: