[Moin-user] Including page changes attachment path resolution

R.Bauer rb.proj at gmail.com
Fri Dec 9 03:50:10 EST 2011


Am 08.12.2011 17:23, schrieb Nikolaus Rath:
> Hi,
> 
> Really no one any idea? (Fullquote below in case the message got lost).
> 
Hi

some ideas:
 * you may be want to use formatter.page.page_name

 * there are themes on the ThemeMarket with an editable Sidebar based
   on a wiki page, see http://moinmo.in/ThemeMarket/Mandarin

 * wikiutil.renderText is also your friend.


Reimar



> Best,
> Nikolaus
> 
> 
> Nikolaus Rath <Nikolaus at rath.org> writes:
>> Hello,
>>
>> I would like to include a static menu bar in every rendered page. The
>> menu bar itself should be editable as a page.
>>
>> I came up with the following code to include another page:
>>
>>     def includepage(self, page_name):
>>         request = self.request
>>         inc_page = Page(request, page_name, formatter=request.formatter)
>>         if not inc_page.exists():
>>             return '<p><strong class="error">Page %s does not exist</strong></p>' % page_name
>>
>>         strfile = StringIO.StringIO()
>>         request.redirect(strfile)
>>         try:
>>             inc_page.send_page(content_only=True,
>>                                omit_footnotes=True,
>>                                count_hit=False)
>>             return strfile.getvalue()
>>         finally:
>>             request.redirect()
>>
>> I then changed my theme's .py file to include the page "navibar":
>>
>>     def navibarpanel(self, d):
>>         html = [
>>             u'<div class="sidepanel"><h1>Quick Links</h1>',
>>             self.navibar(d),
>>             u'</div>',
>>             
>>             u'<div class="sidepanel"><h1>Navigation</h1>',
>>             self.includepage('navibar'),
>>             u'</div>',
>>             ]
>>         return u''.join(html) 
>>
>>         
>> This works nicely, but there is one problem: if, in any page, I refer to
>> an attachment as [[attachment:bla.zip]], then MoinMoin looks for bla.zip
>> in the "navibar" page rather than the page I'm actually viewing.
>>
>>
>> Is there a way to fix this problem? Or is my entire approach wrong?
> 
> 
>    -Nikolaus
> 






More information about the Moin-user mailing list