"""
        IncludeUrlContentWiki macro for MoinMoin 1.6
        
        Get the content from an URL, process it as wiki markup, and return those
        formatted results. 
        
        I personally use this in cases where I have a web server
        process to dynamically generate content that relies on wiki
        features like macros, smileys, table layout rules, etc.
        
        Usage: <<IncludeUrlContentWiki( http://foo.com/wikimarkup )>>
        
        Originally written by:
        2005-03-31 Steve Poole, stevep@wrq.com 
        
        Updated by:
        2008-02-11 Dexter Arver, http://moinmo.in/counterpoke

        @copyright: 2008 Dexter Arver
        @license: GNU GPL, see COPYING for details
"""

import urllib
from MoinMoin import wikiutil

def execute( macro, url ):
    request = macro.request
    try:
        text = urllib.urlopen( url ).read()
    except IOError:
        text = "{{{ IncludeUrlContentWiki failed on " + url + " }}}"
    Parser = wikiutil.searchAndImportPlugin(request.cfg, "parser", request.page.pi['format'])
    return wikiutil.renderText(request, Parser, text, line_anchors=False)
