FW: [Zope] dtml-if fustration!

Greg Conway greg@gmlnt.com
Sun, 25 Aug 2002 19:31:11 +0100


forget that, it doesn't work when called without the variable in the request
:(

any other knowledgeable zope soul out there fancy taking pity on a
struggling newbie?

many thanks!!

Regards,

Greg.

>> -----Original Message-----
>> From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Greg
>> Conway
>> Sent: 25 August 2002 19:20
>> To: Ausum Studio
>> Cc: Zope@Zope. Org
>> Subject: RE: [Zope] dtml-if fustration!
>>
>>
>> Hi Ausum,
>>
>> You've helped me enough.... using the code you sent me before I
>> continued to
>> play, and this seems to work...
>>
>> (not extensively tested as yet though, but looks good!!)
>>
>>   <dtml-if "_.getattr(REQUEST,OuterVar) is not None">
>>
>> so many many thanks!!
>>
>> and yes, you're right, and it would probably be faster in python as well,
>> but that's for another day... :)
>>
>> regards,
>>
>> Greg.
>>
>> >> -----Original Message-----
>> >> From: Ausum Studio [mailto:ausum_studio@hotmail.com]
>> >> Sent: 25 August 2002 19:13
>> >> To: Greg Conway
>> >> Subject: Re: [Zope] dtml-if fustration!
>> >>
>> >>
>> >> Hello again, Greg. I'd really like to help you, as I have
>> >> struggled myself
>> >> with DTML at its moment. But I need a whole case explanation.
>> I'm a bit
>> >> confused trying to understand what you need, from the code
>> you've posted.
>> >>
>> >> At the end, you'll see how easy it woud've been to use a python script
>> >> instead. :)
>> >>
>> >>
>> >> Ausum
>> >>
>> >>
>> >> p.s. Don't need to follow this thread in the list.
>> >>
>> >>
>> >> ----- Original Message -----
>> >> From: "Greg Conway" <greg@gmlnt.com>
>> >> To: "Ausum Studio" <ausum_studio@hotmail.com>
>> >> Cc: "Zope@Zope. Org" <zope@zope.org>
>> >> Sent: Sunday, August 25, 2002 12:59 PM
>> >> Subject: RE: [Zope] dtml-if fustration!
>> >>
>> >>
>> >> > Hi Ausum,
>> >> >
>> >> > The variable in question is as follows...
>> >> >
>> >> > REQUEST.CustomLinkVars contains ['SelectStudentID']
>> >> >
>> >> > and all the other vars in the code snippet are initialised
>> within the
>> >> loop.
>> >> >
>> >> > Hope this sheds more light on it!
>> >> >
>> >> > Regards,
>> >> >
>> >> > Greg
>> >> >
>> >> >
>> >> > >> -----Original Message-----
>> >> > >> From: Ausum Studio [mailto:ausum_studio@hotmail.com]
>> >> > >> Sent: 25 August 2002 18:49
>> >> > >> To: Greg Conway
>> >> > >> Subject: Re: [Zope] dtml-if fustration!
>> >> > >>
>> >> > >>
>> >> > >> Please send me examples of the content of the variables involved.
>> >> > >>
>> >> > >>
>> >> > >> Ausum
>> >> > >>
>> >> > >>
>> >> > >> ----- Original Message -----
>> >> > >> From: "Greg Conway" <greg@gmlnt.com>
>> >> > >> To: "Ausum Studio" <ausum_studio@hotmail.com>
>> >> > >> Sent: Sunday, August 25, 2002 12:38 PM
>> >> > >> Subject: RE: [Zope] dtml-if fustration!
>> >> > >>
>> >> > >>
>> >> > >> > Hi Ausum,
>> >> > >> >
>> >> > >> > Thanks, but (!!) the problem with that is that the value
>> >> > >> 'SelectStudentID'
>> >> > >> > is still hard-coded in!
>> >> > >> >
>> >> > >> > I have tried modifying it as follows...
>> >> > >> >
>> >> > >> >   <dtml-in "REQUEST.CustomLinkVars">
>> >> > >> >     <dtml-let Counter=sequence-index>
>> >> > >> >       <dtml-let OuterVar=sequence-item>
>> >> > >> >
>> >> > >> >         <dtml-if "_.hasattr(REQUEST.CustomLinkVars[Counter],
>> >> > >> OuterVar) and
>> >> > >> >
>> REQUEST.CustomLinkVars[Counter].getattr(REQUEST,OuterVar) is not
>> >> None">
>> >> > >> >
>> >> > >> >           do something when SelectStudentID has any value
>> >> > >> >
>> >> > >> >         </dtml-if>
>> >> > >> >
>> >> > >> >       </dtml-let>
>> >> > >> >     </dtml-let>
>> >> > >> >   </dtml-in>
>> >> > >> >
>> >> > >> > ...and I also tried....
>> >> > >> >
>> >> > >> >         <dtml-if "_.hasattr(REQUEST.CustomLinkVars[Counter],
>> >> > >> OuterVar) and
>> >> > >> > REQUEST.CustomLinkVars[Counter].OuterVar is not None">
>> >> > >> >
>> >> > >> >
>> >> > >> > but neither work, the code in the middle doesn't get executed
>> >> > >> using either
>> >> > >> > of these :(
>> >> > >> >
>> >> > >> > any further ideas?
>> >> > >> >
>> >> > >> > many thanks.
>> >> > >> >
>> >> > >> > regards,
>> >> > >> >
>> >> > >> > Greg.
>> >> > >> >
>> >> > >> > >> -----Original Message-----
>> >> > >> > >> From: zope-admin@zope.org
>> >> [mailto:zope-admin@zope.org]On Behalf Of
>> >> > >> Ausum
>> >> > >> > >> Studio
>> >> > >> > >> Sent: 25 August 2002 18:20
>> >> > >> > >> To: zope@zope.org
>> >> > >> > >> Subject: Re: [Zope] dtml-if fustration!
>> >> > >> > >>
>> >> > >> > >>
>> >> > >> > >> <dtml-if "REQUEST.StoredVar.has_key('SelectStudentID') and
>> >> > >> > >> REQUEST.StoredVar.SelectStudentID is not None">
>> >> > >> > >>     do something when SelectStudebtID has any value
>> >> > >> > >> </dtml-if>
>> >> > >> > >>
>> >> > >> > >> or
>> >> > >> > >>
>> >> > >> > >> <dtml-if "_.hasattr(REQUEST.StoredVar,
>> 'SelectStudentID') and
>> >> > >> > >> REQUEST.StoredVar.SelectStudentID is not None">
>> >> > >> > >>     do something when SelectStudebtID has any value
>> >> > >> > >> </dtml-if>
>> >> > >> > >>
>> >> > >> > >> Ausum
>> >> > >> > >>
>> >> > >> > >>
>> >> > >> > >>
>> >> > >> > >> ----- Original Message -----
>> >> > >> > >> From: "Greg Conway" <greg@gmlnt.com>
>> >> > >> > >> To: "Ausum Studio" <ausum_studio@hotmail.com>
>> >> > >> > >> Cc: "Zope@Zope. Org" <zope@zope.org>
>> >> > >> > >> Sent: Sunday, August 25, 2002 11:24 AM
>> >> > >> > >> Subject: RE: [Zope] dtml-if fustration!
>> >> > >> > >>
>> >> > >> > >>
>> >> > >> > >> > Hi Ausum,
>> >> > >> > >> >
>> >> > >> > >> > Thanks for the reply. What I actually mean is -
>> the name of
>> >> > >> > >> the variable I
>> >> > >> > >> > want the value of is stored inside another variable, in
>> >> > >> the request.
>> >> > >> > >> >
>> >> > >> > >> > For example...
>> >> > >> > >> >
>> >> > >> > >> > REQUEST.StoredVar[1] contains SelectStudentID
>> >> > >> > >> >
>> >> > >> > >> > and I want to perform a dtml-if condition based on whether
>> >> > >> > >> SelectStudentID
>> >> > >> > >> > contains a value or not!
>> >> > >> > >> >
>> >> > >> > >> > So to get this value I perform a
>> >> '_.getattr(REQUEST,StoredVar[1])'
>> >> > >> > >> command.
>> >> > >> > >> >
>> >> > >> > >> > But I cannot seem to do this within a <dtml-if ... >
>> >> > >> > >> statement, it throws
>> >> > >> > >> up
>> >> > >> > >> > an error if the variable does not exist,
>> presumably because
>> >> > >> > >> I'm trying to
>> >> > >> > >> > work through an extra layer of variables....
>> >> > >> > >> >
>> >> > >> > >> > just to make life complicated :)
>> >> > >> > >> >
>> >> > >> > >> > hope this is now clearer, any help much appreciated!
>> >> > >> > >> >
>> >> > >> > >> > Regards,
>> >> > >> > >> >
>> >> > >> > >> > Greg.
>> >> > >> > >> >
>> >> > >> > >> > >> -----Original Message-----
>> >> > >> > >> > >> From: zope-admin@zope.org
>> >> > >> [mailto:zope-admin@zope.org]On Behalf Of
>> >> > >> > >> Ausum
>> >> > >> > >> > >> Studio
>> >> > >> > >> > >> Sent: 24 August 2002 18:39
>> >> > >> > >> > >> To: zope@zope.org
>> >> > >> > >> > >> Subject: Re: [Zope] dtml-if fustration!
>> >> > >> > >> > >>
>> >> > >> > >> > >>
>> >> > >> > >> > >> What is the "next pass"?. Do you mean within the
>> >> same page?
>> >> > >> > >> > >> If so, you don't need to declare the variable,
>> as long as
>> >> it's
>> >> > >> > >> > >> been already
>> >> > >> > >> > >> defined for the whole page. Just use <dtml-var
>> SelectSID>
>> >> > >> anywhere.
>> >> > >> > >> > >>
>> >> > >> > >> > >> Now, if you need to change its value, and then
>> use it on
>> >> > >> > >> the remaining
>> >> > >> > >> > >> portion on the rendered page, the anwser is
>> the same, use
>> >> > >> <dtml-var
>> >> > >> > >> > >> SelectSID>. You don't need to use the
>> "REQUEST.SelectSID"
>> >> part.
>> >> > >> > >> > >>
>> >> > >> > >> > >>
>> >> > >> > >> > >> Ausum
>> >> > >> > >> > >>
>> >> > >> > >> > >>
>> >> > >> > >> > >> ----- Original Message -----
>> >> > >> > >> > >> From: "Greg Conway" <greg@gmlnt.com>
>> >> > >> > >> > >> To: "Zope@Zope. Org" <zope@zope.org>
>> >> > >> > >> > >> Sent: Saturday, August 24, 2002 11:56 AM
>> >> > >> > >> > >> Subject: [Zope] dtml-if fustration!
>> >> > >> > >> > >>
>> >> > >> > >> > >>
>> >> > >> > >> > >> > Hi all,
>> >> > >> > >> > >> >
>> >> > >> > >> > >> > I have a fustrating problem with dtml-if's!!
>> >> I've tried to
>> >> > >> > >> > >> work round it
>> >> > >> > >> > >> in
>> >> > >> > >> > >> > many ways, but there is probably an easy one I am
>> >> overlooking
>> >> > >> > >> > >> knowing my
>> >> > >> > >> > >> > luck...
>> >> > >> > >> > >> >
>> >> > >> > >> > >> > Anyway... Consider the following dtml-if statement:
>> >> > >> > >> > >> >
>> >> > >> > >> > >> >     <dtml-if SelectSID>
>> >> > >> > >> > >> >       SelectSID = <dtml-var SelectSID>
>> >> > >> > >> > >> >       <dtml-call "REQUEST.set('SelectSID',
>> SelectSID)">
>> >> > >> > >> > >> >     </dtml-if>
>> >> > >> > >> > >> >
>> >> > >> > >> > >> > This works okay, and stores the variable
>> >> SelectSID in the
>> >> > >> > >> > >> request for the
>> >> > >> > >> > >> > code to pick up again on it's next pass.
>> >> > >> > >> > >> >
>> >> > >> > >> > >> > However, on the next pass, the variable
>> >> SelectSID doesn't
>> >> > >> > >> exist! As
>> >> > >> > >> the
>> >> > >> > >> > >> > variable is now REQUEST.SelectSID - and the
>> >> following code
>> >> > >> doesn't
>> >> > >> > >> > >> work....
>> >> > >> > >> > >> >
>> >> > >> > >> > >> >     <dtml-if "REQUEST.SelectSID">
>> >> > >> > >> > >> >       SelectSID = <dtml-var SelectSID>
>> >> > >> > >> > >> >       <dtml-call "REQUEST.set('SelectSID',
>> >> > >> REQUEST.SelectSID)">
>> >> > >> > >> > >> >     </dtml-if>
>> >> > >> > >> > >> >
>> >> > >> > >> > >> > ...as an error is thrown up if REQUEST.SelectSID
>> >> > >> doesn't exist!
>> >> > >> > >> > >> >
>> >> > >> > >> > >> > Anybody got a simple answer to my dilemma?!!
>> >> > >> > >> > >> >
>> >> > >> > >> > >> > Many thanks for any help!
>> >> > >> > >> > >> >
>> >> > >> > >> > >> > Regards,
>> >> > >> > >> > >> >
>> >> > >> > >> > >> > Greg Conway.
>> >> > >> > >> > >> >
>> >> > >> > >> > >> > This electronic transmission and any files
>> >> attached to it
>> >> are
>> >> > >> > >> strictly
>> >> > >> > >> > >> > confidential and intended solely for the addressee.
>> >> > >> If you are
>> >> > >> not
>> >> > >> > >> > >> > the intended addressee, you must not disclose, copy
>> >> > >> or take any
>> >> > >> > >> action
>> >> > >> > >> > >> > in reliance of this transmission. If you have
>> >> received this
>> >> > >> > >> > >> > transmission in error, please notify us by return
>> >> > >> and delete the
>> >> > >> > >> same.
>> >> > >> > >> > >> > Further enquiries/returns can be posted to
>> >> > >> postmaster@gmlnt.com
>> >> > >> > >> > >> > Thank you.
>> >> > >> > >> > >> >
>> >> > >> > >> > >> > _______________________________________________
>> >> > >> > >> > >> > 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 )
>> >> > >> > >> > >> >
>> >> > >> > >> > >>
>> >> > >> > >> > >> _______________________________________________
>> >> > >> > >> > >> 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 )
>> >> > >> > >> >
>> >> > >> > >> > This electronic transmission and any files
>> attached to it are
>> >> > >> strictly
>> >> > >> > >> > confidential and intended solely for the addressee.
>> >> If you are
>> >> not
>> >> > >> > >> > the intended addressee, you must not disclose, copy
>> >> or take any
>> >> > >> action
>> >> > >> > >> > in reliance of this transmission. If you have
>> received this
>> >> > >> > >> > transmission in error, please notify us by return
>> >> and delete the
>> >> > >> same.
>> >> > >> > >> > Further enquiries/returns can be posted to
>> >> postmaster@gmlnt.com
>> >> > >> > >> > Thank you.
>> >> > >> > >> >
>> >> > >> > >> > _______________________________________________
>> >> > >> > >> > 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 )
>> >> > >> > >> >
>> >> > >> > >>
>> >> > >> > >> _______________________________________________
>> >> > >> > >> 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 )
>> >> > >> > >>
>> >> > >> >
>> >> > >> > This electronic transmission and any files attached to it are
>> >> strictly
>> >> > >> > confidential and intended solely for the addressee. If
>> you are not
>> >> > >> > the intended addressee, you must not disclose, copy or take any
>> >> action
>> >> > >> > in reliance of this transmission. If you have received this
>> >> > >> > transmission in error, please notify us by return and
>> delete the
>> >> same.
>> >> > >> > Further enquiries/returns can be posted to postmaster@gmlnt.com
>> >> > >> > Thank you.
>> >> > >> >
>> >> > >>
>> >> >
>> >> > This electronic transmission and any files attached to it
>> are strictly
>> >> > confidential and intended solely for the addressee. If you are not
>> >> > the intended addressee, you must not disclose, copy or take
>> any action
>> >> > in reliance of this transmission. If you have received this
>> >> > transmission in error, please notify us by return and
>> delete the same.
>> >> > Further enquiries/returns can be posted to postmaster@gmlnt.com
>> >> > Thank you.
>> >> >
>> >>
>>
>> This electronic transmission and any files attached to it are strictly
>> confidential and intended solely for the addressee. If you are not
>> the intended addressee, you must not disclose, copy or take any action
>> in reliance of this transmission. If you have received this
>> transmission in error, please notify us by return and delete the same.
>> Further enquiries/returns can be posted to postmaster@gmlnt.com
>> Thank you.
>>
>> _______________________________________________
>> 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 )
>>

This electronic transmission and any files attached to it are strictly
confidential and intended solely for the addressee. If you are not
the intended addressee, you must not disclose, copy or take any action
in reliance of this transmission. If you have received this
transmission in error, please notify us by return and delete the same.
Further enquiries/returns can be posted to postmaster@gmlnt.com
Thank you.