[Moin-user] interwiki include macro

james bardin jbardin at bu.edu
Sun Dec 16 00:59:53 EST 2007

On Dec 15, 2007 2:10 PM, Shchupak, Vitaliy <Vitaliy.Shchupak at deshaw.com>

>  You could use RequestCLI to execute the Include macro in another request
> using something like this:
> from MoinMoin.request import RequestCLI
> from MoinMion.user import User
> from MoinMoin.formatter.text_html import Formatter
> def execute(macro, args):
>     # <extract wikiname from args>
>     subreq = RequestCLI('localhost/' + wikiname)
>     subreq.user = user.User(subreq, name=macro.request.user.name)
>     formatter = Formatter(subreq)
>     subreq.formatter = formatter
>     # now call the Include macro from here on subreq...
>     ...
> Vitaliy
Thanks! That's too easy! I'm working on 1.6+1.7 code, so I had to use
request_cli.Request, but otherwise I just inserted the above into the
Request macro. Now comes something a little trickier - I need to rewrite the
links. I know I can do this the dirty way (by parsing the html output from
the macro), but I'd like a cleaner solution, and I'm a little confused whats
getting formatted where?

The links come out formatted for the current wiki, but the css
class="nonexistent" is set from the included wiki. In the end I think I want
to rewrite the links as interwiki links pointing to the same page as was
originally intended, but currently I just don't want valid-looking links
pointing to nonexistent pages.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/moin-user/attachments/20071216/dcfc7fd0/attachment.html>

More information about the Moin-user mailing list