#9183 closed defect (fixed)
[patch] trac.wiki.formatter.wiki_to_outline misses req=None keyword argument.
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | normal | Milestone: | 0.11.8 |
Component: | wiki system | Version: | 0.11-stable |
Severity: | minor | Keywords: | outline |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description (last modified by )
If one tries to use wiki_to_outline from trac.wiki.formatter if raises an exception because req variable is not found in scope.
Simple fix for this forgotten keyword argument is:
-
formatter.py
1440 1440 return Markup(out.getvalue()) 1441 1441 1442 1442 def wiki_to_outline(wikitext, env, db=None, 1443 absurls=False, max_depth=None, min_depth=None): 1443 absurls=False, max_depth=None, min_depth=None, 1444 req=None): 1444 1445 if not wikitext: 1445 1446 return Markup() 1446 1447 abs_ref, href = (req or env).abs_href, (req or env).href
Attachments (0)
Change History (8)
comment:1 by , 15 years ago
comment:2 by , 15 years ago
I've seen that as well. But did not comment on that, only trying to fix the obvious error.
Found the obviously missing keyword argument because I was looking for a way to easily parse wiki markup (including macro's) from a macro. But ended up using a subclass of Template in my macro and doing the basic wrapping code myself.
Maybe I did approach my problem the wrong way but some convenience functions would be useful.
Saying that I would be in favour of removing these particular functions.
There's two reasons I can think of not too; (1) not to put more tickets on 0.12 milestone (2) not to create backward incompatibility for plugin/macro writers.
Usage of wiki_to_* functions on trac-hack:
$ find trac-hacks-trunk -type f -regex ".*0\.11.*\.py" -exec grep -H 'import wiki_to_' {} \; | wc -l 40 $ find trac-hacks-trunk -type f -regex ".*0\.12.*\.py" -exec grep -H 'import wiki_to_' {} \; | wc -l 2
(there not many 0.12 plugins in the repository but still :)
comment:3 by , 15 years ago
Component: | general → wiki system |
---|
I'll mark those functions as deprecated.
comment:5 by , 15 years ago
Keywords: | outline added |
---|---|
Owner: | set to |
Severity: | normal → minor |
comment:6 by , 15 years ago
Description: | modified (diff) |
---|
comment:7 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:8 by , 15 years ago
Milestone: | 0.12 → 0.11.7.1 |
---|
Patch applied on 0.11-stable in [9411]. However, you really shouldn't be using the
wiki_to_*
functions anymore, and use theformat_to*
functions instead.Actually, as the
wiki_to_*
functions were pre-0.11, I would even suggest removing them in 0.12. They are actually partly broken:abs_href
andhref
locals are not used.context
is created fromreq
, which can beNone
inwiki_to_oneliner()
and certainly isNone
inwiki_to_outline()
. In that case,absurls
isn't used either, andcontext.href
isNone
, which will certainly be problematic further down.So we should either remove them, or fix them correctly (which I'm not sure how to do). Thoughts?