Trying to get tree working
Hi * Maybe this is a stupid question but I just can not get it working. I have a page from which the user can view basic item data and which has a link to a page to display the bill of material of the item. <TD bgcolor="#97bae6" width="20%"> <dtml-with "_(abs_path=bmpsiq.absolute_url())"> <a href="&dtml-abs_path;?ps_par=<dtml-var pt_part>" target="main"> Stuklijst </a> </dtml-with> </TD> To get the bill of material I have the following sql method: <params>ps_par</params> select ps_comp, ps_start, ps_end from ps_mstr <dtml-sqlgroup where> <dtml-sqltest ps_par type=string op=eq> <dtml-and> <dtml-sqlgroup> ps_start = ? <dtml-or> ps_start <= today </dtml-sqlgroup> </dtml-sqlgroup> The dtml method to display the tree is : <dtml-let ps_comp=ps_par> <dtml-tree id=ps_comp branches_expr="ps_childLookup(ps_par=ps_comp)"> <b><dtml-var ps_comp></b> <dtml-var ps_start> </dtml-tree> </dtml-let> It works for the first time but when I try to expand it I get a key error on ps_par. What goes wrong?? Hope somebody can help Frans -- Frans C. H. Schneider <mailto:f.schneider@nido.nl> NIDO Universal Machines BV <http://www.nido.nl> Industriestraat 34 <mailto:info@nido.nl> PO Box 30 tel. +31 (0) 548 370 000 7450 AA Holten fax +31 (0) 548 370 233 the Netherlands
Frans C.H. Schneider writes:
... <dtml-let ps_comp=ps_par> <dtml-tree id=ps_comp branches_expr="ps_childLookup(ps_par=ps_comp)"> <b><dtml-var ps_comp></b> <dtml-var ps_start> </dtml-tree> </dtml-let>
It works for the first time but when I try to expand it I get a key error on ps_par.
What goes wrong?? I do not have an answer for your question.
But you should get a traceback and this traceback should tell you where the "KeyError" is detected. This may give you a hint... Dieter
Frans C.H. Schneider writes:
... <dtml-let ps_comp=ps_par> <dtml-tree id=ps_comp branches_expr="ps_childLookup(ps_par=ps_comp)"> <b><dtml-var ps_comp></b> <dtml-var ps_start> </dtml-tree> </dtml-let>
It works for the first time but when I try to expand it I get a key error on ps_par.
What goes wrong?? I do not have an answer for your question.
But you should get a traceback and this traceback should tell you where the "KeyError" is detected. This may give you a hint...
Dieter
This is the traceback. Error Type: KeyError Error Value: ps_par Traceback (innermost last): File /opt/Zope-2.4.2-src/lib/python/ZPublisher/Publish.py, line 223, in publish_module File /opt/Zope-2.4.2-src/lib/python/ZPublisher/Publish.py, line 187, in publish File /opt/Zope-2.4.2-src/lib/python/Zope/__init__.py, line 226, in zpublisher_exception_hook (Object: Artikelen) File /opt/Zope-2.4.2-src/lib/python/ZPublisher/Publish.py, line 171, in publish File /opt/Zope-2.4.2-src/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: bmpsiq) File /opt/Zope-2.4.2-src/lib/python/ZPublisher/Publish.py, line 112, in call_object (Object: bmpsiq) File /opt/Zope-2.4.2-src/lib/python/OFS/DTMLDocument.py, line 199, in __call__ (Object: bmpsiq) File /opt/Zope-2.4.2-src/lib/python/DocumentTemplate/DT_String.py, line 546, in __call__ (Object: bmpsiq) File /opt/Zope-2.4.2-src/lib/python/DocumentTemplate/DT_Let.py, line 146, in render (Object: ps_comp=ps_par) KeyError: (see above) I guess this has to do with the ps_par not being in the namespace the moment I try to expend the tree: it was passed from the calling screen in the first place. If I replace the line with dtml-let ps_comp=ps_par> with dtml-let ps_comp="'partnumber I know'"> it works fine for the item I specify with the partnumber. TIA Frans
Frans C.H. Schneider writes:
Frans C.H. Schneider writes:
... <dtml-let ps_comp=ps_par> <dtml-tree id=ps_comp branches_expr="ps_childLookup(ps_par=ps_comp)"> <b><dtml-var ps_comp></b> <dtml-var ps_start> </dtml-tree> </dtml-let>
It works for the first time but when I try to expand it I get a key error on ps_par.
What goes wrong?? I do not have an answer for your question.
But you should get a traceback and this traceback should tell you where the "KeyError" is detected. This may give you a hint... ... This is the traceback.
Error Type: KeyError Error Value: ps_par
Traceback (innermost last): .... (Object: bmpsiq) File /opt/Zope-2.4.2-src/lib/python/DocumentTemplate/DT_Let.py, line 146, in render (Object: ps_comp=ps_par) KeyError: (see above)
I guess this has to do with the ps_par not being in the namespace the moment I try to expend the tree: it was passed from the calling screen in the first place. If I replace the line with dtml-let ps_comp=ps_par> with dtml-let ps_comp="'partnumber I know'"> it works fine for the item I specify with the partnumber. I think, I understand:
* "ps_par" is a parameter that comes from the request. * When you enter your DTML object for the first time, then the request contains a "ps_par" from the form * When you expand a node in the tree, you create a new request, but this one is lacking the "ps_par" parameter... Your options: * There is an "urlparam_expr" patch for Zope's TreeTag somewhere on zope.org that would allow you to write: <dtml-tree .... urlparam_expr="'ps_par=%s' % ps_par" ...> to pass the parameter (this assumes, your "ps_par" does not contain characters invalid in query strings. Otherwise, you would need to "url_quote_plus" the value.... * You can use a cookie to pass the value around as I did it in my "DocFinder" product <http://www.dieter.handshake.de/pyprojects/zope> This assumes, your "ps_par" does not contain characters invalid in cookies... * If you use sessions anyway, you can store your "ps_par" in a session object. Dieter
Thanks, I was afraid it was something like this. It is somewhat messy I think and I was hoping for something real simple. Frans On Wed, 5 Dec 2001, Dieter Maurer wrote:
Frans C.H. Schneider writes:
Frans C.H. Schneider writes:
... <dtml-let ps_comp=ps_par> <dtml-tree id=ps_comp branches_expr="ps_childLookup(ps_par=ps_comp)"> <b><dtml-var ps_comp></b> <dtml-var ps_start> </dtml-tree> </dtml-let>
It works for the first time but when I try to expand it I get a key error on ps_par.
What goes wrong?? I do not have an answer for your question.
But you should get a traceback and this traceback should tell you where the "KeyError" is detected. This may give you a hint... ... This is the traceback.
Error Type: KeyError Error Value: ps_par
Traceback (innermost last): .... (Object: bmpsiq) File /opt/Zope-2.4.2-src/lib/python/DocumentTemplate/DT_Let.py, line 146, in render (Object: ps_comp=ps_par) KeyError: (see above)
I guess this has to do with the ps_par not being in the namespace the moment I try to expend the tree: it was passed from the calling screen in the first place. If I replace the line with dtml-let ps_comp=ps_par> with dtml-let ps_comp="'partnumber I know'"> it works fine for the item I specify with the partnumber. I think, I understand:
* "ps_par" is a parameter that comes from the request.
* When you enter your DTML object for the first time, then the request contains a "ps_par" from the form
* When you expand a node in the tree, you create a new request, but this one is lacking the "ps_par" parameter...
Your options:
* There is an "urlparam_expr" patch for Zope's TreeTag somewhere on zope.org that would allow you to write:
<dtml-tree .... urlparam_expr="'ps_par=%s' % ps_par" ...>
to pass the parameter (this assumes, your "ps_par" does not contain characters invalid in query strings. Otherwise, you would need to "url_quote_plus" the value....
* You can use a cookie to pass the value around as I did it in my "DocFinder" product
<http://www.dieter.handshake.de/pyprojects/zope>
This assumes, your "ps_par" does not contain characters invalid in cookies...
* If you use sessions anyway, you can store your "ps_par" in a session object.
Dieter
participants (3)
-
Dieter Maurer -
Frans C.H. Schneider -
Schneider Frans