[Grok-dev] update() in grok.View
Tim Cook
timothywayne.cook at gmail.com
Thu Jul 30 07:02:36 EDT 2009
DUH!!! I'm comparing strings from the form to ints in the statements.
Problem solved.
On Thu, 2009-07-30 at 07:59 -0300, Tim Cook wrote:
> I have a View as shown below. In my immcalc.pt all of the values are
> output correctly but the IF statements in the Hep B section never
> evaluate to true. IOW self.resultstxt is always "". I get the "No
> Immunizations Needed at this time." result or if I comment out that IF
> statement I get an empty resultstxt.
>
> If I do the same thing in the Python interpreter, it works fine.
>
> Any ideas?
>
>
>
> *******************************************************************************
> class immCalc(grok.View):
> """ This view demonstrates the typical if/elif construct for making
> these decisions."""
>
> grok.context(dsedemo)
>
> def update(self):
> examDate =
> datetime(*(time.strptime(self.request['form.examDate'], '%Y-%m-%
> d')[0:6]))
> dob = datetime(*(time.strptime(self.request['form.dob'], '%Y-%
> m-%d')[0:6]))
> self.age = ( examDate - dob ).days
> self.hepatitisB = self.request['form.hepatitisB']
> self.tetravalent = self.request['form.tetravalent']
> self.polio = self.request['form.polio']
> self.rotavirus = self.request['form.rotavirus']
> self.resultstxt = "" # info for physcian
>
> # Hep B
> if self.age < 30 and self.hepatitisB == 0:
> self.resultstxt += "Needs Hepatitis B #1; "
> if self.age >= 30 and self.age < 60 and self.hepatitisB == 1:
> self.resultstxt += "Needs Hepatitis B #2; "
> if self.age >= 30 and self.age < 60 and self.hepatitisB == 0:
> self.resultstxt += "Needs Hepatitis B #1; "
> if self.age >= 120 and self.age < 180 and self.hepatitisB == 0:
> self.resultstxt += "Needs Hepatitis B #1; "
> if self.age >= 120 and self.age < 180 and self.hepatitisB == 1:
> self.resultstxt += "Needs Hepatitis B #2; "
> if self.age >= 120 and self.age < 180 and self.hepatitisB == 2:
> self.resultstxt += "Needs Hepatitis B #3; "
>
>
> # No Immunizations Needed at this time.
> if self.resultstxt == "":
> self.resultstxt = "No Immunizations Needed at this time."
> # age check
> if self.age > 180:
> self.resultstxt = "Sorry this child is too old to assess
> with this application."
>
> *********************************************************************************************
> Thanks,
> Tim
>
>
>
--
Timothy Cook, MSc
Health Informatics Research & Development Services
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
Skype ID == timothy.cook
***************************************************************
*You may get my Public GPG key from popular keyservers or *
*from this link http://timothywayne.cook.googlepages.com/home *
***************************************************************
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
Url : http://mail.zope.org/pipermail/grok-dev/attachments/20090730/5e9a8ae9/attachment.bin
More information about the Grok-dev
mailing list