Changeset 842

Show
Ignore:
Timestamp:
06/11/06 02:21:24 (2 years ago)
Author:
athomas
Message:

PollMacro:

0.10ism workaround

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • pollmacro/0.9/tracpoll/tracpoll.py

    r675 r842  
    55from trac.core import * 
    66from trac.perm import IPermissionRequestor 
    7 from trac.wiki.macros import WikiMacroBase 
    87from trac.util import sorted, escape 
    98from trac.wiki.formatter import wiki_to_oneliner 
     
    8685        return out.getvalue() 
    8786 
     87try: 
     88    from trac.wiki.macros import WikiMacroBase 
     89except ImportError: 
     90    # TODO Remove this when ported to 0.10 
     91    class WikiMacroBase(Component): 
     92        """Abstract base class for wiki macros.""" 
     93 
     94        implements(IWikiMacroProvider) 
     95        abstract = True 
     96 
     97        def get_macros(self): 
     98            """Yield the name of the macro based on the class name.""" 
     99            name = self.__class__.__name__ 
     100            if name.endswith('Macro'): 
     101                name = name[:-5] 
     102            yield name 
     103 
     104        def get_macro_description(self, name): 
     105            """Return the subclass's docstring.""" 
     106            return inspect.getdoc(self.__class__) 
     107 
     108        def render_macro(self, req, name, content): 
     109            raise NotImplementedError 
    88110 
    89111class PollMacro(WikiMacroBase): 
     
    148170                summary = wiki_to_oneliner(summary, self.env) 
    149171 
    150                 all_votes.append((str(id), "ticket prio%s%s" % 
    151                                   (priority, ticket_count % 2 and ' even' or ''), 
     172                all_votes.append((str(id), "ticket prio%s%s%s" % 
     173                                  (priority, ticket_count % 2 and ' even' or '', 
     174                                  ticket['status'] == 'closed' and ' closed' or ''), 
    152175                                  summary)) 
    153176                ticket_count += 1