[Zope] Continued problem tal:condition
zope
zope@stylusinc.net
Wed, 21 Aug 2002 11:39:24 +0530
Hi All
Thanks once again for all the help you have given me.
I have tried out the suggestions.
Now all my macros are in the same page.
I m am trying to use :
<div tal:condition="request/form/lkid | nothing">
<tal:block define="mName
python:here.oms.Users.lib.pset_links(lkid=request.form['lkid'])">
<metal:block use-macro="container/zptmac_memall/macros/?mName">
List
</metal:block>
</tal:block>
</div>
Or else :
<div tal:condition="request.form.get('lkid') == 't' ">
<metal:block
use-macro="container/zptmac_memall/macros/zptmac_alllist">
List
</metal:block>
</div>
In both cases the earlier error of :
exceptions.KeyError on id in "<PythonExpr request.form['id'] == 't' or
nothing>"
The problem is that the value for "lkid" even when it is passed does not
call the macro.
Irrespective of whatever value i pass i cant see the macros although the
error is not being shown.
Why is this?
I would like to state the problem again.
I have a page template that on loading first should not show me any macro
after i send the form variable via a link the page should get refreshed and
now the pag e should also show me the macro apart from what it was showing
earlier.
now there are no errors being shown but i still cant view the macros after
the value has been passed.
Could you please help me out.
Thanks and Best Regards
John Kunchandy
Original message::
exceptions.KeyError on id in "<PythonExpr request.form['id'] == 't' or
> nothing>"
> -------------------------------------------------------^
> Could you tell me how I can rewrite this so that the first time the page
is
> loaded even if there is no value for "id" the page will be shown .
> And only if I pass a form variable it should execute.
Try replacing "request.form['id'] == 't' or nothing" with:
request.form.get(id')=='t'
cheers,
Chris
On Tue, 2002-08-20 at 22:03, KevinL wrote:
> How about:
>
> <div tal:define="macroName request/form/id">
> <metal:block use-macro="container/zptmac_memtask/macros/?macroName">
> List
> </metal:block>
> </div>
>
> Combined with renaming your "id" field in your forms (or your macro
> names, either will do) so they match? That munges the whole list of
> tal:conditions down to something more manageable...
Heh. After posting this, I looked closer at your list below, and
realised you're altering both the macro file name, and the name of the
macro inside the file.
That'd require that you be able to replace multiple elements of the
macro name, rather than a single. That's not doable atm. I still
reckon it should be... Then you'd be covered by a tal:define="macroName
string:container/zptmac_${request/id}task/macros/zptmac_${request/id}list".
Alternately, you can make all macros in macro files be called the same
thing - so you end up with a file "zptmac_mempending", which has a macro
called "std", and a "zptmac_memtask" which also has a macro called
"std", and you just alter one element of the path to the macro, based on
the id from the form.
KevinL
> > On Tuesday, August 20, 2002, at 07:18 , zope wrote:
> >
> > > Hi All
> > > I am trying to execute a macro only if a condition is satisified.
> > > The code I am using is:
> > >
> > > <div tal:condition="python:request.form['id'] == 't' | nothing"
> > > metal:use-macro="container/zptmac_memtask/macros/zptmac_taskslist">
> > > List
> > > </div>
> > > <div tal:condition="python:request.form['id'] == 'p' | nothing"
> > > metal:use-macro="container/zptmac_mempending/macros/zptmac_pendlist">
> > > List
> > > </div>
> > > <div tal:condition="python:request.form['id'] == 'w' | nothing"
> > > metal:use-macro="container/zptmac_memweek/macros/zptmac_weeklist">
> > > List
> > > </div>
> > > <div tal:condition="python:request.form['id'] == 'a' | nothing"
> > > metal:use-macro="container/zptmac_memall/macros/zptmac_alllist">
> > > List
> > > </div>
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.381 / Virus Database: 214 - Release Date: 8/2/2002