[ZCM] [ZC] 1046/ 3 Reject "? syntax in TALES Path Expressions"

Collector: Zope Bugs, Features, and Patches ... zope-coders-admin at zope.org
Fri Oct 24 13:50:01 EDT 2003


Issue #1046 Update (Reject) "? syntax in TALES Path Expressions"
 Status Rejected, Zope/bug medium
To followup, visit:
  http://zope.org/Collectors/Zope/1046

==============================================================
= Reject - Entry #3 by andym on Oct 24, 2003 1:50 pm

 Status: Pending => Rejected

You know I just tried it again and it works just fine for me. I wonder what code didnt work, should have written it down. 

Sorry about that, I'll reject this until I can prove otherwise.
________________________________________
= Comment - Entry #2 by evan on Oct 24, 2003 1:39 pm

Please be more specific about the code that's failing for you.  "?var" works fine for me in casual testing.
________________________________________
= Request - Entry #1 by andym on Sep 10, 2003 7:43 pm

According to the Zope Book "A limited amount of indirection is possible by using a variable name prefixed with ? as a path segment. The variable must contain a string, which replaces that segment before the path is traversed."

But this doesnt seem to work. This because although in line 124 of PageTemplates/Expression.py the string is chopped off it is never evaluated. In _eval it just sees a list and adds it in. Then passes this on to restrictedTraverse. That value needs to be evaluated.

(16:12:08) andym: anyone know about using ? in tales to do variable substitution?
(16:12:16) andym: its in the docs but dont work here
(16:13:09) ToyMan [~stuq at user-0cevdks.cable.mindspring.com] entered the room.
(16:16:35) dlarose left the room (quit: "ChatZilla 0.8.26 [Mozilla rv:1.4b/20030507]").
(16:17:57) JimRoepcke: andym: ? ?
(16:22:53) andym: From Appendix C: "A limited amount of indirection is possible by using a variable name prefixed with ? as a path segment. The variable must contain a string, which replaces that segment before the path is traversed."
(16:23:09) andym: eg: here/?tname/macros/?mname
(16:23:20) JimRoepcke: wow sweet
(16:23:31) JimRoepcke: but it don't workee huh
(16:23:34) andym: not here
(16:24:01) andym: Invalid variable name "path here" in expression 'path here/?objs', at line 9, column 4
(16:24:04) JimRoepcke: do you see any code that would suggest that was actually implemented?
(16:24:20) andym: not yet
(16:24:36) andym: but abscense of code is normally me looking in the wrong palce 
(16:25:06) JimRoepcke: well don't be too surprised if you looked in the right places this time 
(16:26:15) JimRoepcke: ah
(16:26:21) JimRoepcke: PageTemplates/Expressions.py
(16:26:29) JimRoepcke: class SubPathExpr:
(16:26:30) JimRoepcke: ...
(16:26:49) JimRoepcke: if e[:1] == '?' and _valid_name(e[1:]):
(16:26:55) andym: ah
(16:26:58) andym: well spotted
(16:26:59) JimRoepcke: dp.append((i, e[1:]))
(16:27:05) JimRoepcke: notice :1 and 1:
(16:27:08) JimRoepcke: bug?
(16:27:21) andym: no thats right
(16:27:25) JimRoepcke: ok
(16:28:23) andym: but its not evaluating it is it?
(16:28:43) andym: hmm
(16:29:17) JimRoepcke: that would happen in _eval wouldn't it?
(16:29:50) JimRoepcke: ahhhhhh
(16:30:04) JimRoepcke: yes it doesn't actually evaluate it
(16:30:51) andym: line 140?
(16:31:52) JimRoepcke: of?
(16:32:15) andym: i should run pdb, would be clearer
(16:32:36) JimRoepcke: you need to get the value of e[1:] out of the context and append that to dp
(16:33:09) JimRoepcke: that is, the value of the variable with the name e[1:]
(16:33:55) JimRoepcke: you don't have access to the expression context in __init__
(16:34:01) JimRoepcke: only in _eval
(16:34:05) JimRoepcke: (of SubPathExpr)
(16:34:44) andym: right
(16:34:47) JimRoepcke: the check for ? should be done again and evaluated in _eval
(16:35:16) ***andym tootles over to the collector
(16:37:04) andym: the collector on zope.org sucks so bad
==============================================================




More information about the Zope-Collector-Monitor mailing list