#6144 closed defect (wontfix)
"wiki_to_html" fails when called without a "req" object
Reported by: | 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)
Change History (10)
comment:1 by , 17 years ago
follow-up: 3 comment:2 by , 17 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
This will not happen as a req is needed for security enforcement and URL establishment.
follow-ups: 4 6 comment:3 by , 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.
follow-up: 5 comment:4 by , 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)
comment:5 by , 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.
comment:6 by , 17 years ago
Resolution: | wontfix |
---|---|
Status: | closed → reopened |
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?
follow-up: 8 comment:7 by , 17 years ago
Resolution: | → wontfix |
---|---|
Status: | reopened → closed |
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 … ;-) ).
comment:8 by , 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.
Maybe there should be a test-case, too, which checks if "wiki_to_html" works with a "None" req object.