At 08:01 AM 6/25/2005 -0700, Andi Vajda wrote:

I've added getKind() and iterItems() classmethods to schema.Item, so that you can more easily get at kinds or do KindQueries. For example, you can replace code like this:

      kind = "//parcels/osaf/contentmodel/mail/IMAPAccount"
      for item in ItemQuery.KindQuery().run([view.findPath(kind)]):
          if item.isActive and item.host and item.username:
              yield item

with this:

      for item in Mail.IMAPAccount.iterItems(view):
          if item.isActive and item.host and item.username:
              yield item

That's a great idea. I'll add the same to the Kind class. There already is an iterAttributes() method there. An iterItems() makes sense.
It should work as follows:

        for item in mailItem.itsKind.iterItems():
            .....

Of course, if mailItem is an instance of a schema.Item (and currently only the repository core schema isn't), the existing iterItems() classmethod allows you to do this:

         for item in mailItem.iterItems():

So, the Kind method would only be useful in situations when you already have a kind object -- and I'll be trying to eliminate those situations as much as possible. :)


Ultimately though, the hope is that there is going to be a lot less use of KindQuery once the new ItemCollection/Query/AbstractSet stuff becomes mainstream. Basically, a KindQuery should be a query of last resort. Using sets, which ultimately wrap one or more ref collections is a lot more efficient.

I'm not sure I follow you here; there will still be situations where the desired behavior is to obtain all items of a particular kind, and the ideal API is simply to ask a class to iterate its items. For example, all items of the Web.Server kind need to be found in order to set up listening ports.

Of course, if efficiency requires a different implementation for iterItems() then that is easily achieved since there is now only one place needed to change it. (Not entirely true, actually, as there are still KindQuery uses floating around that I haven't converted yet for one reason and another.)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Open Source Applications Foundation "Dev" mailing list
http://lists.osafoundation.org/mailman/listinfo/dev

Reply via email to