Attachment 'IncludeUrlContent.py'

Download

   1 #format python
   2 
   3 """
   4 	IncludeUrlContent macro for MoinMoin
   5 	
   6 	by Erin Mulder (meara @ alumni.princeton.edu)
   7 	
   8 	This is a very simple macro that just grabs the content at the
   9 	specified URL and includes it as raw HTML.   It doesn't strip
  10 	out HTML header tags, so it's most useful for URLs that return
  11 	HTML fragments rather than entire sites.  I'm using it to pull
  12         in fragments generated by automated processes (e.g. backup
  13         status, documentation exports, etc.).
  14 	
  15 	Usage: [[IncludeUrlContent(http://www.xyz.org/someFragment.html)]]
  16 """
  17 
  18 import urllib
  19 
  20 def execute(macro, url):
  21 	try:
  22 		return macro.formatter.rawHTML(urllib.urlopen(url).read())
  23 	except IOError:
  24 		return "Error reading " + url		

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-01-29 20:21:36, 0.7 KB) [[attachment:IncludeUrlContent.py]]
 All files | Selected Files: delete move to page copy to page

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