Attachment 'IncludeUrlContentWiki.py'

Download

   1 """
   2         IncludeUrlContentWiki macro for MoinMoin 1.3
   3         
   4         Get the content from an URL, process it as wiki markup, and return those
   5         formatted results. 
   6         
   7         I personally use this in cases where I have a web server
   8         process to dynamically generate content that relies on wiki
   9         features like macros, smileys, table layout rules, etc.
  10         
  11         Usage: [[IncludeUrlContentWiki( http://foo.com/wikimarkup )]]
  12         
  13         2005-03-31 Steve Poole, stevep@wrq.com        
  14         
  15 """
  16 
  17 import urllib, StringIO
  18 from MoinMoin.parser import wiki
  19 
  20 def execute( macro, url ):
  21 
  22     try:
  23         out = StringIO.StringIO()
  24         macro.request.redirect( out )
  25         try:
  26             wikitext = urllib.urlopen( url ).read()
  27         except IOError:
  28             wikitext = "{{{ IncludeUrlContentWiki failed on " + url + " }}}"
  29         wikifier = wiki.Parser( wikitext, macro.request )
  30         wikifier.format( macro.formatter )
  31         result = out.getvalue()
  32     finally:
  33         macro.request.redirect()
  34         del out
  35 
  36     return result

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2008-02-12 00:43:52, 1.1 KB) [[attachment:IncludeUrlContentWiki-1.6.py]]
  • [get | view] (2008-11-19 23:33:08, 1.2 KB) [[attachment:IncludeUrlContentWiki-1.8.py]]
  • [get | view] (2005-04-01 01:15:07, 1.1 KB) [[attachment:IncludeUrlContentWiki.py]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.