[Zope] filter(), map(), and lambda

ed colmar element@immersivearts.com
Fri, 14 Apr 2000 08:22:39 -0600


Hey all!

	I've been trying to achieve this for a few months now, with no success.
hopefully someone will be able to shed some light on this one...

	I have a python product that contains 3 sub-classes.  One of these is
called "events".  In my primary class I have a method "eventValues", which
works great to return sub objects, but It also returns sub-objects that are
NOT events.

------------------

    def eventValues(self):
        """ return list of sub-objects  """
        return map(lambda x, p=self: x.__of__(p), self.data.map(self.ids))

------------------
So, I tried adding in a filter() to remove out the meta_types that I don't
want.
------------------

    def eventFilterValues(self):
        """ return list of only events  """
        rlist = map(lambda x, p=self: x.__of__(p), self.data.map(self.ids))
        rlist = filter(lambda x,p=self : p.data[x].meta_type ==
'SREventPost', rlist)
        return rlist

------------------

These calls are not working...  I get a TypeError

Error Type: TypeError
Error Value: Bucket __getitem__ expected integer key

Any ideas how to make this work?

-ed-