Description
Problem with sub pages and how to get the right URL from whithin a parser
Steps to reproduce
Create a page with a subpage e.g.
http://localhost:8080/OnePage/TwoPage
- then attach from modern/img the files idea.png and tired.png to this page
call the parser_problem from this page
from MoinMoin.action import AttachFile Dependencies = [] class Parser: def __init__(self, raw, request, **kw): self.raw = raw self.request = request self.form = request.form self._ = request.getText def format(self, formatter): current_pagename=formatter.page.page_name self.request.write(current_pagename) image='idea.png' example='tired.png' small={} small['src']=AttachFile.getAttachUrl(current_pagename,image,self.request) image_link=formatter.image(**small) webn_url="%(pagename)s?action=AttachFile&do=view&target=%(example)s" % { "pagename":current_pagename, "example":example} txt=(formatter.url(1,webn_url)+image_link+formatter.url(0)) self.request.write(txt)
Result
- current_pagename looks good
- I got if I look at the url in the status bar or if I copy it from the symbol
http://localhost:8080/OnePage/OnePage/TwoPage?action=AttachFile&do=view&target=tired.png
Where does the double OnePage comes from?
All is ok if I use only OnePage.
If I try
http://localhost:8080/OnePage/TwoPage/ThreePage
I got
http://localhost:8080/OnePage/TwoPage/OnePage/TwoPage/ThreePage?action=AttachFile&do=view&target=tired.png
That's strange. May be I am blind and I have it in the code.
-- ReimarBauer 2005-08-06 20:37:43
- Are you referring to image_link or webn_url here?
image_link is right shown, if I send it to the browser webn_url is right OnePage/TwoPage?action=AttachFile&do=view&target=tired.png but then if I build the URL by the formatter it goes wrong
Please use action.AttachFile.getAttachUrl in both cases.
I got another solution. The hint with the absolute URL was perfect. It is easier by using wikiutil.link_tag.
text= 'text to show' url = 'where to jump' link = wikiutil.link_tag(self.request, url, text=text, formatter=formatter) self.request.write(link)
Thanks! -- ReimarBauer 2005-08-07 16:20:23
Details
MoinMoin Version |
1.3.5 |
OS and Version |
debian sarge |
Python Version |
2.3 |
Server Setup |
standalone |
Server Details |
localhost |
Workaround
Discussion
Plan
- Priority:
- Assigned to:
- Status: Not a bug. the formatter wants absolute URLs