Grails
  1. Grails
  2. GRAILS-6229

Allow Filters to depend on other Filters, to control filter handler ordering

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.3.1
    • Component/s: None
    • Labels:
      None

      Description

      Currently, filters can not require that other filters in the chain be executed before they are. This prevents filters that rely on other filters to set up their environment from functioning correctly.

      Allow any filter to define a dependsOn property with a list of filter classes that should be executed before it.

      Example:

      class MyFilters {
      def dependsOn = [MyOtherFilters.class]

      def filters = {
      filter1(uri:"/*") {
      before =

      { request.isAwesome = true; }

      after = {}
      afterView = {}
      }
      }
      }

      class MyOtherFilters {
      def filters = {
      filter1(uri:"/*") {
      before = {
      if (request.isAwesome)

      { // do something awesome }

      }
      after = {}
      afterView = {}
      }
      }
      }

        Issue Links

          Activity

          Hide
          David Castro added a comment -

          I've got the code ready already, emailing dev list to sanity check the idea.

          Show
          David Castro added a comment - I've got the code ready already, emailing dev list to sanity check the idea.
          Hide
          Graeme Rocher added a comment -

          Jeff - David has submitted a pull request. The relevant commit is here: http://github.com/arimus/grails-core/commit/5acd518ece0caf6b69309335b186033819df0f1d

          Please apply for 1.3.1

          Show
          Graeme Rocher added a comment - Jeff - David has submitted a pull request. The relevant commit is here: http://github.com/arimus/grails-core/commit/5acd518ece0caf6b69309335b186033819df0f1d Please apply for 1.3.1
          Hide
          Jeff Scott Brown added a comment -

          Graeme,

          Will do. Right now under certain circumstances I think some filters are being skipped with the patch. I will commit the feature once I can track that down.

          Show
          Jeff Scott Brown added a comment - Graeme, Will do. Right now under certain circumstances I think some filters are being skipped with the patch. I will commit the feature once I can track that down.
          Hide
          Jeff Scott Brown added a comment -

          RE: previous comment... I think the problem had to do with a bad testing scenario I had. I do not think filters are being skipped.

          Show
          Jeff Scott Brown added a comment - RE: previous comment... I think the problem had to do with a bad testing scenario I had. I do not think filters are being skipped.
          Hide
          David Castro added a comment -

          Thanks guys. BTW, how do we go about updating the documentation for the new feature? Is it something I can get access to or is someone else going to take care of adding it?

          Show
          David Castro added a comment - Thanks guys. BTW, how do we go about updating the documentation for the new feature? Is it something I can get access to or is someone else going to take care of adding it?
          Hide
          Jeff Scott Brown added a comment -

          David,

          The Grails User Guide (http://grails.org/doc/latest/) is open source. The git repo is available at http://github.com/grails/grails-doc. You may fork that repo and send a pull request. Take a look at the README.txt at the root of that project for notes on how to build the docs, and in particular how to take advantage of grails.home to significantly speed up the process of building the docs since you already have a local copy of the Grails source code.

          Show
          Jeff Scott Brown added a comment - David, The Grails User Guide ( http://grails.org/doc/latest/ ) is open source. The git repo is available at http://github.com/grails/grails-doc . You may fork that repo and send a pull request. Take a look at the README.txt at the root of that project for notes on how to build the docs, and in particular how to take advantage of grails.home to significantly speed up the process of building the docs since you already have a local copy of the Grails source code.
          Hide
          Graeme Rocher added a comment -

          David - Before we commit this would you mind signing the external committer agreement. For significant patches we are asked to do this for each project:

          https://support.springsource.com/spring_committer_signup

          It is basically legal protection to prevent a Linux/SCO like situation.

          Show
          Graeme Rocher added a comment - David - Before we commit this would you mind signing the external committer agreement. For significant patches we are asked to do this for each project: https://support.springsource.com/spring_committer_signup It is basically legal protection to prevent a Linux/SCO like situation.
          Hide
          David Castro added a comment -

          Certainly, I plan to continue contributing.

          I've signed the agreement. Do you need my confirmation number or can you just look it up by my name/email?

          Show
          David Castro added a comment - Certainly, I plan to continue contributing. I've signed the agreement. Do you need my confirmation number or can you just look it up by my name/email?
          Show
          Jeff Scott Brown added a comment - Feature Added: http://github.com/grails/grails-core/commit/5785b780d0a9bc37af0cd7a433eee0d6eaadb511 http://github.com/grails/grails-core/commit/0522d991ac8220d3f9b8488529486e3db9339ef6 http://github.com/grails/grails-doc/commit/381aed931aa6fae6dba180addcb2c2afb76534de

            People

            • Assignee:
              Jeff Scott Brown
              Reporter:
              David Castro
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development