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

Jonothan Farr jfarr@real.com
Mon, 17 Apr 2000 14:39:32 -0700


If your class is subclassed from ObjectManager, just use
objectValues(spec="SREventPost")

-jfarr

----- Original Message -----
From: ed colmar <element@immersivearts.com>
To: <zope@zope.org>
Sent: Friday, April 14, 2000 7:22 AM
Subject: [Zope] filter(), map(), and lambda


> 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-
>
>
>
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )
>