Opened 18 years ago
Closed 18 years ago
#53 closed defect (wontfix)
select() result can't be used as a string
Reported by: | anonymous | Owned by: | cmlenz |
---|---|---|---|
Priority: | minor | Milestone: | |
Component: | Template processing | Version: | 0.2 |
Keywords: | Cc: |
Description (last modified by cmlenz)
Hi,
I have encountered a problem using py:match that doesn't look right to me.
In my templates, I use customs elements like <tag ident="xhtml">XHTML</tag> and try to turn them into links with the following line:
<py:match path="tag"> <a href="${url_for('tag', ident=select('@ident'))}">${select('text()')}</a> </py:match>
Although the ident attribute's value is inserted with
title="${select('@ident')}"
and
title="${(select('@ident'))}"
it is not with
href="${url_for('tag', ident=select('@ident'))}"
which uses an URL generation function from Routes. Since the round braces don't seem to be the problem, is it the apostrophs or the equal sign of the keyword argument? I think the markup extract shown above definitely makes sense and did already work with Kid (with some syntax changes, of course).
What is the cause of this behaviour? I use the latest Markup version from SVN as of today.
Thanks, Jochen Kupperschmidt
Change History (5)
comment:1 Changed 18 years ago by anonymous
comment:2 Changed 18 years ago by cmlenz
- Component changed from General to Template processing
- Milestone 0.3 deleted
- Priority changed from major to minor
- Summary changed from select() inside py:match sometimes not working properly? to select() result can't be used as a string
While I agree that having to wrap select() in str() is a bit of a kludge, I don't currently see a good way around that.
select() always returns Stream objects, and if you pass it to a function in an expression, who says that function doesn't actually expect a stream?
I'm changing the summary to reflect the issue, but I currently don't see a solution.
comment:3 Changed 18 years ago by anonymous
As long as the docs reflect that select() returns a stream (which they currently don't, as far as I can tell), that would be sufficient, I think.
comment:4 Changed 18 years ago by cmlenz
- Description modified (diff)
(improved description formatting)
comment:5 Changed 18 years ago by jochen.kupperschmidt@…
- Resolution set to wontfix
- Status changed from new to closed
Since the initial point of this ticket is not a defect and a way to work with it is documented here, I'm closing this one.
Oops! After some more tries, an exception informed me that I was dealing with a Stream instance. After a look into that class, I came up with this, doing what I expected:
So easy.
But would it be useful to have Markup directly convert it into a string for use in expressions like this?