Attachment 'SecureInclude.py'

Download

   1 """
   2     MoinMoin - SecureInclude  macro
   3 
   4     This macro will do an include of the given page if the user has permission
   5     to view it. If the user has no permissions, nothing will be displayed. The
   6     page is displayed in a light-grey background with a dotted border to help
   7     indicate to the user they are viewing "internal information". By default
   8     a header is placed above the section saying
   9         "Internal - Internal - Internal"
  10     This can be overridden in the wikiconfig.py by setting the
  11     'SecureIncludeBanner' variable
  12 
  13     Example usage: <<SecureInclude(PageName)>>
  14 
  15     @license: GNU GPL, see COPYING for details.
  16     @author: Andy Doan <andy.doan@linaro.org>
  17 """
  18 
  19 from MoinMoin import wikiutil
  20 from MoinMoin.macro import Include
  21 
  22 divfmt = """
  23 <style type="text/css">
  24 div.SecureInclude {border: 1px dashed; background-color: #F3F5F7; }
  25 h2.SecureInclude {text-align: center; font-style: italic; font-size: 12pt; color: #aaaaaa;}
  26 </style>
  27 <div class="SecureInclude">
  28 <h2 class="SecureInclude">%s</h2>
  29 %s
  30 </div>
  31 """
  32 
  33 def macro_SecureInclude(macro, page):
  34 
  35     banner = 'Internal - Internal - Internal'
  36     banner = getattr(macro.request.cfg, 'SecureIncludeBanner', banner)
  37 
  38     html = Include.execute(macro, page)
  39     if not html:
  40     	#the user does not have permission
  41 	return ""
  42 
  43     return macro.formatter.rawHTML(divfmt % (banner, html))

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] (2011-06-15 20:47:28, 47.9 KB) [[attachment:SecureInclude-authenticated.png]]
  • [get | view] (2011-06-15 20:47:07, 28.0 KB) [[attachment:SecureInclude-not-authenticated.png]]
  • [get | view] (2011-06-15 20:40:11, 1.3 KB) [[attachment:SecureInclude.py]]
 All files | Selected Files: delete move to page copy to page

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