You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bloodhound.apache.org by Apache Bloodhound <bl...@incubator.apache.org> on 2012/12/12 10:52:24 UTC

[Apache Bloodhound] #298: Exception from missing req.chrome['labels'] in filter_stream

#298: Exception from missing req.chrome['labels'] in filter_stream
-----------------------+-----------------------
 Reporter:  gjm        |      Owner:  nobody
     Type:  defect     |     Status:  new
 Priority:  major      |  Milestone:  Release 4
Component:  dashboard  |    Version:
 Keywords:             |
-----------------------+-----------------------
 This is related to #294 in a sense as it is another case when the
 {{{req.chrome['labels']}}} dictionary is potentially unavailable. In the
 former case it was because it was causing premature lazy evaluation,
 before a function was curried to specify the ultimate handler.

 This new case is may be because an exception can stop the
 {{{post_process_request}}} from executing so that it is not available in
 the {{{filter_stream}}} method, where it is now required so that errors
 are correctly whitelabelled.

 I suggest that we move the whitelabelling config evaluation into a
 separate helper method (in case there are situations where the dictionary
 is required elsewhere) and add {{{req.chrome['labels']}}} in the
 {{{filter_stream}}} method.

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

Re: [Apache Bloodhound] #298: Exception from missing req.chrome['labels'] in filter_stream

Posted by Apache Bloodhound <bl...@incubator.apache.org>.
#298: Exception from missing req.chrome['labels'] in filter_stream
------------------------+-----------------------
  Reporter:  gjm        |      Owner:  gjm
      Type:  defect     |     Status:  closed
  Priority:  major      |  Milestone:  Release 4
 Component:  dashboard  |    Version:
Resolution:  fixed      |   Keywords:
------------------------+-----------------------
Changes (by gjm):

 * status:  accepted => closed
 * resolution:   => fixed


Comment:

 r1420831 fixes

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

Re: [Apache Bloodhound] #298: Exception from missing req.chrome['labels'] in filter_stream

Posted by Gary Martin <ga...@wandisco.com>.
Hi,

There are a couple of issues I have come across recently with the 
accessibility of changes made to req.chrome that developers should be 
aware of. I certainly learnt a bit from analysing these problems. 
Grammar issues aside, the description in #298 attempts to summarise 
these potential gotchas. Perhaps we will want a page that lists these 
kinds of discoveries on the wiki.

Cheers,
     Gary


On 12/12/12 09:52, Apache Bloodhound wrote:
> #298: Exception from missing req.chrome['labels'] in filter_stream
> -----------------------+-----------------------
>   Reporter:  gjm        |      Owner:  nobody
>       Type:  defect     |     Status:  new
>   Priority:  major      |  Milestone:  Release 4
> Component:  dashboard  |    Version:
>   Keywords:             |
> -----------------------+-----------------------
>   This is related to #294 in a sense as it is another case when the
>   {{{req.chrome['labels']}}} dictionary is potentially unavailable. In the
>   former case it was because it was causing premature lazy evaluation,
>   before a function was curried to specify the ultimate handler.
>
>   This new case is may be because an exception can stop the
>   {{{post_process_request}}} from executing so that it is not available in
>   the {{{filter_stream}}} method, where it is now required so that errors
>   are correctly whitelabelled.
>
>   I suggest that we move the whitelabelling config evaluation into a
>   separate helper method (in case there are situations where the dictionary
>   is required elsewhere) and add {{{req.chrome['labels']}}} in the
>   {{{filter_stream}}} method.
>
> -- Ticket URL: <https://issues.apache.org/bloodhound/ticket/298> 
> Apache Bloodhound <https://issues.apache.org/bloodhound/> The Apache 
> Bloodhound (incubating) issue tracker


Re: [Apache Bloodhound] #298: Exception from missing req.chrome['labels'] in filter_stream

Posted by Apache Bloodhound <bl...@incubator.apache.org>.
#298: Exception from missing req.chrome['labels'] in filter_stream
------------------------+-----------------------
  Reporter:  gjm        |      Owner:  gjm
      Type:  defect     |     Status:  accepted
  Priority:  major      |  Milestone:  Release 4
 Component:  dashboard  |    Version:
Resolution:             |   Keywords:
------------------------+-----------------------
Changes (by gjm):

 * owner:  nobody => gjm
 * status:  new => accepted


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

Re: [Apache Bloodhound] #298: Exception from missing req.chrome['labels'] in filter_stream

Posted by Apache Bloodhound <bl...@incubator.apache.org>.
#298: Exception from missing req.chrome['labels'] in filter_stream
------------------------+-----------------------
  Reporter:  gjm        |      Owner:  gjm
      Type:  defect     |     Status:  accepted
  Priority:  major      |  Milestone:  Release 4
 Component:  dashboard  |    Version:
Resolution:             |   Keywords:
------------------------+-----------------------

Comment (by gjm):

 Looking again, that patch doesn't quite work so it looks like, if we keep
 the suggested {{{_get_whitelabelling}}} method, we still need
 {{{
 #!python
 req.chrome['labels'] = self._get_whitelabelling()
 }}}
 in the {{{post_process_request}}} and just
 {{{
 #!python
 app_short = self._get_whitelabelling()['application_short']
 }}}
 in the {{{filter_stream}}} method.

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

Re: [Apache Bloodhound] #298: Exception from missing req.chrome['labels'] in filter_stream

Posted by Apache Bloodhound <bl...@incubator.apache.org>.
#298: Exception from missing req.chrome['labels'] in filter_stream
------------------------+-----------------------
  Reporter:  gjm        |      Owner:  gjm
      Type:  defect     |     Status:  accepted
  Priority:  major      |  Milestone:  Release 4
 Component:  dashboard  |    Version:
Resolution:             |   Keywords:
------------------------+-----------------------

Comment (by gjm):

 I believe something like this should fix:

 {{{
 #!diff
 Index: bloodhound_theme/bhtheme/theme.py
 ===================================================================
 --- bloodhound_theme/bhtheme/theme.py    (revision 1420498)
 +++ bloodhound_theme/bhtheme/theme.py    (working copy)
 @@ -123,6 +123,22 @@
      implements(IRequestFilter, INavigationContributor, ITemplateProvider,
                 ITemplateStreamFilter)

 +    def _get_whitelabelling(self):
 +        """Gets the whitelabelling config values"""
 +        c = self.env.config
 +        return dict(
 +            application_short = c.get(
 +                'labels', 'application_short', "Bloodhound"),
 +            application_full = c.get(
 +                'labels', 'application_full', "Apache Bloodhound"),
 +            footer_left_prefix = c.get(
 +                'labels', 'footer_left_prefix', ""),
 +            footer_left_postfix = c.get(
 +                'labels', 'footer_left_postfix', ""),
 +            footer_right = c.get(
 +                'labels', 'footer_right', ""),
 +            application_version = ".".join(map(str,
 application_version)))
 +
      # ITemplateStreamFilter methods

      def filter_stream(self, req, method, filename, stream, data):
 @@ -155,6 +171,8 @@
              .select("body//a[contains(@href,'/wiki/%s')]" %
 wiki.GUIDE_NAME) \
              .map(lambda text: wiki.new_name(text), TEXT)

 +        req.chrome['labels'] = self._get_whitelabelling()
 +
          # Rename trac error
          app_short = req.chrome['labels']['application_short']
          tx = tx.end() \
 @@ -197,20 +215,6 @@
                  is_active = active_theme['name'] == this_theme_name
              return is_active

 -        c = self.env.config
 -        req.chrome['labels'] = dict(
 -            application_short = c.get(
 -                'labels', 'application_short', "Bloodhound"),
 -            application_full = c.get(
 -                'labels', 'application_full', "Apache Bloodhound"),
 -            footer_left_prefix = c.get(
 -                'labels', 'footer_left_prefix', ""),
 -            footer_left_postfix = c.get(
 -                'labels', 'footer_left_postfix', ""),
 -            footer_right = c.get(
 -                'labels', 'footer_right', ""),
 -            application_version = ".".join(map(str,
 application_version)))
 -
          links = req.chrome.get('links',{})
          # replace favicon if appropriate
          if self.env.project_icon == 'common/trac.ico':
 }}}

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