incubator-bloodhound-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Apache Bloodhound" <bloodhound-...@incubator.apache.org>
Subject Re: [Apache Bloodhound] #23: quick ticket functionality should check that the ticket module is active
Date Wed, 04 Apr 2012 10:28:45 GMT
#23: quick ticket functionality should check that the ticket module is active
------------------------+-------------------------------------
  Reporter:  gjm        |      Owner:  gjm
      Type:  defect     |     Status:  new
  Priority:  major      |  Milestone:  RC1 for initial release
 Component:  dashboard  |    Version:
Resolution:             |   Keywords:
------------------------+-------------------------------------

Comment (by gjm):

 In the absence of a simpler check, I was thinking of adding these
 functions to the theme.py:
 {{{
 #!python
 def subclasses(cls):
     """recursively get subclasses of a class"""
     for sub in cls.__subclasses__():
         for subsub in subclasses(sub):
             yield subsub
         yield sub

 def get_enabled_component_subclass(env, cls):
     """if the cls is not enabled, attempts to find a subclass which is"""
     if env.is_component_enabled(cls):
         return cls
     for subcls in subclasses(cls):
         if env.is_component_enabled(subcls):
             return subcls
     return None
 }}}

 then, in the {{{post_process_request}}} method, check for the subclasses
 of tickets:

 {{{
 #!python
 tmcls = get_enabled_component_subclass(self.env, TicketModule)
 if tmcls is None:
     tmcls = TicketModule
 tm = tmcls(self.env)
 }}}

 Other suggestions would be welcome though.

-- 
Ticket URL: <https://issues.apache.org/bloodhound/ticket/23#comment:2>
Apache Bloodhound <https://issues.apache.org/bloodhound/>
The Apache Bloodhound (incubating) issue tracker

Mime
View raw message