Back to index

moin  1.9.0~rc2
groups.py
Go to the documentation of this file.
00001 # -*- coding: iso-8859-1 -*-
00002 """
00003     MoinMoin - MoinMoin.formatter.groups
00004 
00005     @copyright: 2009 MoinMoin:DmitrijsMilajevs
00006     @license: GNU GPL, see COPYING for details.
00007 """
00008 
00009 from MoinMoin.formatter import FormatterBase
00010 from MoinMoin import wikiutil
00011 
00012 class Formatter(FormatterBase):
00013     """
00014     Collect members of a group and format nothing.
00015 
00016     Group members are stored in the members attribute.
00017     """
00018 
00019     def __init__(self, request, **kw):
00020         FormatterBase.__init__(self, request, **kw)
00021 
00022         self.members = []
00023         self._bullet_list_level = 0
00024         self._inside_link = False
00025         self._new_member = ''
00026 
00027     def bullet_list(self, on, **kw):
00028         if on:
00029             self._bullet_list_level += 1
00030         else:
00031             self._bullet_list_level -= 1
00032 
00033         assert self._bullet_list_level >= 0
00034 
00035         return self.null()
00036 
00037     def listitem(self, on, **kw):
00038         if self._bullet_list_level == 1:
00039             if not on:
00040                 stripped_new_member = self._new_member.strip()
00041                 if stripped_new_member:
00042                     self.members.append(stripped_new_member)
00043             self._new_member = ''
00044         return self.null()
00045 
00046     def text(self, text, **kw):
00047         if self._bullet_list_level == 1 and not self._inside_link:
00048             self._new_member += text
00049         return self.null()
00050 
00051     def pagelink(self, on, pagename='', page=None, **kw):
00052         if self._bullet_list_level == 1:
00053             self._inside_link = on
00054             if not on:
00055                 if not pagename and page:
00056                     pagename = page.page_name
00057                 pagename = wikiutil.normalize_pagename(pagename, self.request.cfg)
00058                 self._new_member += pagename
00059         return self.null()
00060 
00061     def null(self, *args, **kw):
00062         return ''
00063 
00064     # All these must be overriden here because they raise
00065     # NotImplementedError!@#! or return html?! in the base class.
00066     set_highlight_re = rawHTML = url = image = smiley = null
00067     strong = emphasis = underline = highlight = sup = sub = strike = null
00068     code = preformatted = small = big = code_area = code_line = null
00069     code_token = linebreak = paragraph = rule = icon = null
00070     number_list = definition_list = definition_term = definition_desc = null
00071     heading = table = null
00072     table_row = table_cell = attachment_link = attachment_image = attachment_drawing = null
00073     transclusion = transclusion_param = null
00074