Re: [Zope] looping through objectValues, how to get methods?
Hi Ed :-) StarRave marches on I see... I'm assuming mixing_for is a method? > if hasattr(i, 'mixing_for()'): #try to get > mixing_for() method > days_mixing=getattr(i,'mixing_for()') in which case the above should be: if hasattr(i, 'mixing_for'): days_mixing=i.mixing_for() cheers, Chris ___ Zope maillist - [EMAIL PROTECTED] 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 )
Re: [Zope] looping through objectValues, how to get methods?
On Wed, 19 Jul 2000, ed colmar wrote: > I have a method that looks through "objectValues". Using "hasattr" and > "getattr" I can see the variables contained in the object. > > How do I get the values generated from an object's method in a similar > fashion? > > For example: > if hasattr(i, 'djname'): #get djname variable > if hasattr(i, 'mixing_for()'): #try to get > mixing_for() method did you try removing the parenthesis, like: if hasattr(i, 'mixing_for') good luck Jerome ALET - [EMAIL PROTECTED] - http://cortex.unice.fr/~jerome Faculte de Medecine de Nice - http://noe.unice.fr - Tel: 04 93 37 76 30 28 Avenue de Valombrose - 06107 NICE Cedex 2 - FRANCE ___ Zope maillist - [EMAIL PROTECTED] 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 )
RE: [Zope] looping through objectValues, how to get methods?
days_mixing = getattr(i, 'mixing_for') a = days_mixing() > -Original Message- > From: ed colmar [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, July 19, 2000 11:09 AM > To: [EMAIL PROTECTED] > Subject: [Zope] looping through objectValues, how to get methods? > > > I have a method that looks through "objectValues". Using > "hasattr" and > "getattr" I can see the variables contained in the object. > > How do I get the values generated from an object's method in a similar > fashion? > > For example: > > def dj_experince_statistics(self): > """ > > """ > rlist = self.People.objectValues('SRPersonPost') > newbcount=0 > for i in rlist: > if hasattr(i, 'validated'): #get validated variable > if hasattr(i, 'djname'): #get djname variable > if hasattr(i, 'mixing_for()'): #try to get > mixing_for() method > days_mixing=getattr(i,'mixing_for()') > if days_mixing < 730.0: > newbcount=newbcount+1 > return newbcount > > > BTW this does not work. > > Thanks for any suggestions! > > -ed- > > > ___ > Zope maillist - [EMAIL PROTECTED] > 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 ) > ___ Zope maillist - [EMAIL PROTECTED] 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 )
[Zope] looping through objectValues, how to get methods?
I have a method that looks through "objectValues". Using "hasattr" and "getattr" I can see the variables contained in the object. How do I get the values generated from an object's method in a similar fashion? For example: def dj_experince_statistics(self): """ """ rlist = self.People.objectValues('SRPersonPost') newbcount=0 for i in rlist: if hasattr(i, 'validated'): #get validated variable if hasattr(i, 'djname'): #get djname variable if hasattr(i, 'mixing_for()'): #try to get mixing_for() method days_mixing=getattr(i,'mixing_for()') if days_mixing < 730.0: newbcount=newbcount+1 return newbcount BTW this does not work. Thanks for any suggestions! -ed- ___ Zope maillist - [EMAIL PROTECTED] 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 )