Edgewall Software
Modify

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#9183 closed defect (fixed)

[patch] trac.wiki.formatter.wiki_to_outline misses req=None keyword argument.

Reported by: trbs <trbs@…> Owned by: trbs <trbs@…>
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 Christian Boos)

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

     
    14401440    return Markup(out.getvalue())
    14411441
    14421442def 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):
    14441445    if not wikitext:
    14451446        return Markup()
    14461447    abs_ref, href = (req or env).abs_href, (req or env).href

Attachments (0)

Change History (8)

comment:1 by Remy Blank, 14 years ago

Patch applied on 0.11-stable in [9411]. However, you really shouldn't be using the wiki_to_* functions anymore, and use the format_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:

  • The abs_href and href locals are not used.
  • The context is created from req, which can be None in wiki_to_oneliner() and certainly is None in wiki_to_outline(). In that case, absurls isn't used either, and context.href is None, 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?

comment:2 by trbs <trbs@…>, 14 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 why 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 :)

Version 0, edited 14 years ago by trbs <trbs@…> (next)

comment:3 by Christian Boos, 14 years ago

Component: generalwiki system

I'll mark those functions as deprecated.

comment:4 by Christian Boos, 14 years ago

Done in [9427].

comment:5 by Christian Boos, 14 years ago

Keywords: outline added
Owner: set to trbs <trbs@…>
Severity: normalminor

comment:6 by Christian Boos, 14 years ago

Description: modified (diff)

comment:7 by Christian Boos, 14 years ago

Resolution: fixed
Status: newclosed

comment:8 by Christian Boos, 14 years ago

Milestone: 0.120.11.7.1

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain trbs <trbs@…>.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from trbs <trbs@…> to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.