[Zope3-dev] ? vs $
Jeffrey P Shell
jeffrey@cuemedia.com
Fri, 14 Jun 2002 11:52:30 -0600
On 6/14/02 11:34 AM, "Steve Alexander" <steve@cat-box.net> wrote:
> Jim Fulton wrote:
>>
>> The rational for using ? was that ? isn't legal in Zope
>> names.
>>
>> I would prefer to treat this as a non-feature. In fact,
>> I would go so far as to take it out.
>>
>> If someone really wants this, we ought to think harder about
>> how to provide it.
>
> I think it is a useful and concise syntax for a not uncommon requirement.
I agree. But I think it could be more useful (potentially) to use the
String expression syntax, and to run a path through the String expression
engine before doing traversal.
> Consider the current incarnation of the JobBoard example. The method
> JobList.getApprovedIds returns a list of job ids.
>
>
> <tr tal:repeat="jobid context/getApprovedIds">
> <td>
> <a href="jobid" tal:attributes="href jobid">
> <span tal:replace="context/?jobid/summary">A job summary</span></A>
> </td>
> </tr>
I had a case yesterday where I was looping over parts of a compound
document, and needing to render the elements all in-line. To do this, the
final part of the path expression needed to be dynamic. Doing <td
tal:content="structure item/?previewer"> (where previewer was a string
(naming a page template in this case) defined earlier based on the value of
the item) came in very handy.
> The alternative is to use a python expression. I much prefer a simple
> syntax for interpolating paths.
>
> <span tal:replace="python:path('context/%s/summary' % jobid)">
> A job summary</span></A>
And in this case, isn't there an added expense to evaluating a restricted
Python AND path expression at the same time? I wonder how this compares
performance-wise with adding dynamic elements to a path expression with
?foo, or an alternative of evaluating a path through the string expression
engine before traversal?
--
Jeffrey P Shell
www.cuemedia.com