Re: Updated: (MODPYTHON-112) If using filters value of req.phase only valid up till fi
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > Apache Server configuration support > Apache Mod-Python > Re: Updated: (MODPYTHON-112) If using filters value of req.phase only valid up till fi




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Re: Updated: (MODPYTHON-112) If using filters value of req.phase only valid up till fi  
Graham Dumpleton


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
02-25-06 10:50 PM


On 26/02/2006, at 5:58 AM, Jim Gallacher wrote:

> Since we are discussing Python*Filter, can someone explain why it
> is only allowed in the server config context, whereas
> SetInputFilter and related directives are allowed in any context?
> Is this a mod_python feature or a bug, or is it just the way
> filters work?

There are two parts to it. First is the registration of a filter.
Second is saying that
that filter should be used within a particular configuration
container context.

The table used to hold the names of the registered filters is global.
Ie., shared
by the whole server (virtual server??). Because of this, it isn't
possible to say
that the registration of a filter can only be valid within a certain
context.

Although the registration is global, the filter still needs to be
associated with
specific requests using the Set*Filter directives. It is the latter
second step which
constraints it to a specific context.

Not being able to dynamically register filters for only a specific
context, is a bit
limiting, which is why I implemented:

http://issues.apache.org/jira/browse/MODPYTHON-103

With this, in 3.3 you can dynamically register filters implemented in
mod_python.

from mod_python import apache

def uppercase(filter):
s = filter.read()
while s:
filter.write(s.upper())
s = filter.read()
if s is None:
filter.close()

def fixuphandler(req):
req.register_output_filter("UPPERCASE","example::uppercase")
req.add_output_filter("UPPERCASE")
return apache.OK

You might as shown use a fixuphandler() to register a filter to
convert all content
to uppercase and then activate it for the current request.

Even if only static files are being served, they will still pass
through the filter.

The dynamic registration works by mod_python itself being registered
as a
filter under the name MOD_PYTHON on initialisation of mod_python. When a
mod_python filter is dynamically registered using
req.register_*_filter(), the
details are remembered in the per request config. When
req.add_*_filter() is called,
the MOD_PYTHON filter is attached to the request, with some context
being
supplied such that when it is called, it knows to actually delegate
to the
filter registered within the mod_python per request config.

Graham






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 06:03 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register