Edgewall Software
Modify

Opened 17 years ago

Closed 17 years ago

Last modified 17 years ago

#6144 closed defect (wontfix)

"wiki_to_html" fails when called without a "req" object

Reported by: ilias@… Owned by: Christian Boos
Priority: normal Milestone:
Component: wiki system Version: devel
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

Based on the documentation within "context.py" this code should work:

  from trac.wiki.formatter import wiki_to_html
  htmltxt = wiki_to_html('WikiStarter',self.env, None)

It should just format "WikiStarter" to real html link.

The code fails (0.11dev-r5897) with the error:

AttributeError: 'NoneType' object has no attribute 'perm'

The location is here:

File "f:\pj\infra\infra\trac\trac\wiki\api.py", line 345, in _format_link

line 345 of the code:

        if 'WIKI_VIEW' not in req.perm(context):

There should be a check if "req" is available, thus "wiki_to_html" works independent of the existence of the req object.

Attachments (1)

wiki_to_html_without_req.diff (627 bytes ) - added by ilias@… 17 years ago.
Simple patch, please verify

Download all attachments as: .zip

Change History (10)

comment:1 by ilias@…, 17 years ago

Maybe there should be a test-case, too, which checks if "wiki_to_html" works with a "None" req object.

by ilias@…, 17 years ago

Simple patch, please verify

comment:2 by Noah Kantrowitz, 17 years ago

Resolution: wontfix
Status: newclosed

This will not happen as a req is needed for security enforcement and URL establishment.

in reply to:  2 ; comment:3 by Christian Boos, 17 years ago

Replying to nkantrowitz:

This will not happen as a req is needed for security enforcement and URL establishment.

Well, that's true for now, but this is something we'll try to address in future releases, as neither the security enforcement and the URL generation should be dependent on the trac.web layer. In the longer term, off-line wiki processing should be possible.

So, for the time being, "wiki_to_html" will fail when called without a "req" object.

in reply to:  3 ; comment:4 by osimons <simon-code@…>, 17 years ago

Replying to cboos:

So, for the time being, "wiki_to_html" will fail when called without a "req" object.

Actually, not quite true. It will only fail if it encounters items that it needs to check for permissions - like links, which is usually pretty much everything :-)

This works:

htmltxt = wiki_to_html("= A heading =\nAnd some ''markup''.", self.env, None)

in reply to:  4 comment:5 by Noah Kantrowitz, 17 years ago

Replying to osimons <simon-code@bvnetwork.no>:

Replying to cboos:

So, for the time being, "wiki_to_html" will fail when called without a "req" object.

Actually, not quite true. It will only fail if it encounters items that it needs to check for permissions - like links, which is usually pretty much everything :-)

Not to mention that being req-less would make macro expansion tricky.

in reply to:  3 comment:6 by ilias@…, 17 years ago

Resolution: wontfix
Status: closedreopened

Replying to cboos:

Replying to nkantrowitz:

This will not happen as a req is needed for security enforcement and URL establishment.

Well, that's true for now, but this is something we'll try to address in future releases, as neither the security enforcement and the URL generation should be dependent on the trac.web layer. In the longer term, off-line wiki processing should be possible.

So, for the time being, "wiki_to_html" will fail when called without a "req" object.

Can you estimate a Milestone for this?

comment:7 by Christian Boos, 17 years ago

Resolution: wontfix
Status: reopenedclosed

That ticket was about a specific problem:

Based on the documentation within "context.py" this code should work:

  from trac.wiki.formatter import wiki_to_html
  htmltxt = wiki_to_html('WikiStarter',self.env, None)

but:

  • context.py will be gone before 0.11 gets released
  • for the more general problem of separating the web layer and the rendering layer, this is an open question which has not yet a corresponding milestone

So this ticket is a wontfix because the specific problem it raised won't be fixed (you can consider it was a documentation issue within context.py if you want).

(Ilias, you might want to experiment with the new extension we put in place on t.e.o: tickets will delete themselves if they changes too many times from wontfix to reopen … ;-) ).

in reply to:  7 comment:8 by ilias@…, 17 years ago

Replying to cboos: […]

  • for the more general problem of separating the web layer and the rendering layer, this is an open question which has not yet a corresponding milestone

[…]

I assumed that this separation is already existent (docu in context.py seemed to confirm this). Thus i assumed a regression here.

It is now clear that the subsystem "rendering" is directly coupled to "web" (which means that a wiki page cannot be transformed to html without the existence of a web request).

Thanks for the info.

comment:9 by Christian Boos, 17 years ago

Thanks for not having reopened the ticket ;-)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christian Boos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Christian Boos 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.