Attachment 'ShortText-1.3.5-2.py'

Download

   1 # -*- coding: iso-8859-1 -*-
   2 """
   3     MoinMoin - RecommendPage Action Macro
   4 
   5     PURPOSE:
   6         This macro is used to show the first 180 chars of a wikipage
   7 
   8     CALLING SEQUENCE:
   9         [[ShortText(WikiName)]]
  10 
  11     PROCEDURE:
  12        This routine needs the macro RecommendPage
  13 
  14        Please remove the version number from the filename.
  15 
  16     MODIFICATION HISTORY:
  17         @copyright: 2005 by Reimar Bauer (R.Bauer@fz-juelich.de)
  18         @license: GNU GPL, see COPYING for details.
  19         Version: 1.3.4-1
  20         2005-09-09 : Version 1.3.5-2 : bug fixed if acl does not allow to read the routine has crashed before
  21 
  22 
  23 
  24 """
  25 
  26 from MoinMoin.action import RecommendPage
  27 from MoinMoin.Page import Page
  28 
  29 Dependencies = ["pages"]
  30 
  31 
  32 def execute(macro, pagename):
  33     request = macro.request
  34     _ = request.getText
  35 
  36     if request.user.may.read(pagename):
  37         thispage=Page(request,pagename)
  38         thisraw=thispage.get_raw_body()
  39 
  40         given_acl,thisraw = RecommendPage.ACLparse(request, thisraw)
  41         if (len(thisraw) > 180):
  42             return thisraw[0:180]
  43         else:
  44             return thisraw
  45     else:
  46       return "You are not allowed to read (please login)"

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] (2005-05-02 19:43:58, 1.1 KB) [[attachment:ShortText-1.3.4-1.py]]
  • [get | view] (2005-09-09 10:51:06, 1.1 KB) [[attachment:ShortText-1.3.5-2.py]]
  • [get | view] (2008-01-10 14:47:47, 1.5 KB) [[attachment:ShortText-1.6.0-3.py]]
 All files | Selected Files: delete move to page copy to page

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