Re: How to get this value

2009-07-13 Thread Kenneth Gonsalves
On Tuesday 14 Jul 2009 6:01:35 am Karen Tracey wrote: > > Before I posted my code, I formatted them carefully on wordpad. > > However, they became so messy after I posted them. > > > > Is it possible to do anything to clear such a problem? just wondering > > this. > > For short snippets, as this

Re: How to get this value

2009-07-13 Thread Karen Tracey
On Mon, Jul 13, 2009 at 8:22 PM, David wrote: > > Before I posted my code, I formatted them carefully on wordpad. > However, they became so messy after I posted them. > > Is it possible to do anything to clear such a problem? just wondering > this. > For short snippets, as this was, just cut an

Re: How to get this value

2009-07-13 Thread Kenneth Gonsalves
On Tuesday 14 Jul 2009 5:52:51 am David wrote: > Before I posted my code, I formatted them carefully on wordpad. > However, they became so messy after I posted them. > > Is it possible to do anything to clear such a problem? just wondering > this. I would suggest you use a good editor for writin

Re: How to get this value

2009-07-13 Thread David
Before I posted my code, I formatted them carefully on wordpad. However, they became so messy after I posted them. Is it possible to do anything to clear such a problem? just wondering this. On Jul 13, 5:15 pm, David wrote: > Hi Karen, > > Thanks for your long reply. Though this problem h

Re: How to get this value

2009-07-13 Thread David
Hi Karen, Thanks for your long reply. Though this problem has been solved (Thanks to all for your replies, especially Sam), let me explain a little more. The 2nd for loop is actually an embedded loop in the 1st for loop. >From the 1st loop I retrieve some values, and use these values (as "model

Re: How to get this value

2009-07-13 Thread David
Hi Sam, Cool! It works. Thanks so much! On Jul 13, 4:49 pm, Sam Lai wrote: > Try: > > getattr(eachalert, criteria1_metric1) or something similar. look up > the getattr python function. > > On 7/14/09, David wrote: > > > > > > > > > still no lucky... > > > Traceback (most recent call last): >

Re: How to get this value

2009-07-13 Thread Karen Tracey
On Mon, Jul 13, 2009 at 5:36 PM, David wrote: > > Thanks Amit. Here is the problem that I meet. > > alerts = Alert.objects.filter((Q(dataset=dataset1) > > for eachalert in alerts: >e_metric1 = eachalert.criteria1_metric1 > > > Django complains that there is no such item "criteria1_metric1" in

Re: How to get this value

2009-07-13 Thread Sam Lai
Try: getattr(eachalert, criteria1_metric1) or something similar. look up the getattr python function. On 7/14/09, David wrote: > > still no lucky... > > Traceback (most recent call last): > File "", line 1, in > File "/home/dwang/alert/../alert/message/models.py", line 245, in > check_crit

Re: How to get this value

2009-07-13 Thread David
still no lucky... Traceback (most recent call last): File "", line 1, in File "/home/dwang/alert/../alert/message/models.py", line 245, in check_criteria1 metric11 = eachalert.get(criteria1_metric1) AttributeError: 'Alert' object has no attribute 'get' >>> On Jul 13, 3:53 pm, Jav

Re: How to get this value

2009-07-13 Thread Javier Guerra
On Mon, Jul 13, 2009 at 5:48 PM, David wrote: > TypeError: 'Alert' object is unsubscriptable sorry, i was mixing languages. try "e_metric1 = eachalert.get (criteria1_metric1)" -- Javier --~--~-~--~~~---~--~~ You received this message because you are subscribed

Re: How to get this value

2009-07-13 Thread David
Thanks Javier. I got Traceback (most recent call last): File "", line 1, in File "/home/dwang/alert/../alert/message/models.py", line 245, in check_criteria1 metric11 = eachalert[criteria1_metric1] TypeError: 'Alert' object is unsubscriptable >>> any more ideas? I am also googling

Re: How to get this value

2009-07-13 Thread Javier Guerra
On Mon, Jul 13, 2009 at 4:36 PM, David wrote: > > Thanks Amit. Here is the problem that I meet. > > alerts = Alert.objects.filter((Q(dataset=dataset1) > > for eachalert in alerts: >    e_metric1 = eachalert.criteria1_metric1 try "e_metric1 = eachalert[criteria1_metric1]" -- Javier --~--~-

Re: How to get this value

2009-07-13 Thread David
Thanks Amit. Here is the problem that I meet. alerts = Alert.objects.filter((Q(dataset=dataset1) for eachalert in alerts: e_metric1 = eachalert.criteria1_metric1 Django complains that there is no such item "criteria1_metric1" in Alert class. This is correct as Alert class does not have suc

Re: How to get this value

2009-07-13 Thread Amit Sethi
I am not sure what you are trying to do. And the code seems almost unreadable . You could try posting the code to : http://pastebin.com/ Also what might be helpful: What is the problem statement what is this code trying to solve ? What value you want and where ? And what error does django giv

Re: How to get this value

2009-07-13 Thread David
I do not know why the code gets seperated. Here it is. alertcriteria1 = Alert_Criteria1.objects.all() for eachcriterion in alertcriteria1: dataset1 = eachcriterion.dataset criteria1_metric1= eachcriterion.