Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Ticket #394 (defect)

Opened 3 years ago

Last modified 3 years ago

Filters don't act intelligently

Status: closed (wontfix)

Reported by: xin Assigned to: fumanchu
Priority: normal Milestone: 2.2-beta
Component: CherryPy code Keywords: filters
Cc:

Config File:

[global]
;server.filtersRoot = ['filters']     ; SEMI-IMPORTANT LINE A
;server.inputFiltersDict = {'sessAuth': 'sessAuthFilter'}    ; SEMI-IMPORTANT LINE B

sessionFilter.on: True
;sessAuth.on = False

[/members]
;sessAuth.on = True

Some of my code:

class sessAuthFilter(BaseFilter):
  def beforeMain(self):
		
  if cherrypy.request.path.endswith('login'):
    print 'Login'
    return
  elif cherrypy.request.path.endswith('logout'):
    print 'Logout'
    return

class SomeClass():
  def index(self):
    return doStuff()

class MembersOnlyClass(SomeClass):
  _cpFilterList = [sessAuthFilter()]
  def login(self):
    return doLoginStuff()

cherrypy.root = SomeClass()
cherrypy.root.members = MembersOnlyClass()
cherrypy.config.update(file = 'site.ini')
cherrypy.server.start()

I intended to have the sessAuthFilter only operate in the /members 'directory'. With the code listed it works fine, but with the lines in the config file uncommented the Filter would run Once in the root, but twice in /members.

Another thing I noted, the sessionauthenticationfilter as provided by CherryPy-2.1 has a code snippet that will make it only run if its enabled. Shouldn't this be handled by the Filter Controller?

Personally I believe filters should be off by default, and require them to be explicitly turned on.

- xin@xlevus.net

p.s. Make this Ticket Box bigger.

Change History

11/18/05 06:00:41: Modified by rdelon

  • milestone changed from 2.1-final to 2.2-beta.

11/25/05 12:23:06: Modified by fumanchu

  • owner changed from rdelon to fumanchu.
  • status changed from new to assigned.

12/28/05 21:23:24: Modified by fumanchu

  • status changed from assigned to closed.
  • resolution set to wontfix.

Although some of the custom filter mechanisms were broken (fixed in [891]), that doesn't change the resolution of this ticket, which is "don't do that" (don't declare filters twice via two different mechanisms).

Hosted by WebFaction

Log in as guest/cpguest to create tickets