Updated: (MODPYTHON-103) Implement req.add_output_filter().
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 > Updated: (MODPYTHON-103) Implement req.add_output_filter().




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

    Updated: (MODPYTHON-103) Implement req.add_output_filter().  
Graham Dumpleton (JIRA)


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


 
01-08-06 12:46 PM

[ http://issues.apache.org/jira/brows...ON-103?page=all ]

Graham Dumpleton updated MODPYTHON-103:
---------------------------------------

Attachment: grahamd_20060108_2_multiple.diff

You can ignore "grahamd_20060108_1_requestobject.c.diff" now.

I have superseded this with "grahamd_20060108_2_multiple.diff". This is done
 as a context diff as well to make it easier to see where changes need to go
.

This later patch includes support for dynamic registration of new Python fil
ters from a request handler. For example:

from mod_python import apache

def uppercase(filter):
apache.log_error("uppercase")
apache.log_error(filter.name)
apache.log_error(filter.handler)
apache.log_error("is_input "+repr(filter.is_input))
s = filter.read()
while s:
filter.write(s.upper())
s = filter.read()
if s is None:
apache.log_error("close")
filter.close()
apache.log_error("end")

def handler(req):
req.register_output_filter("UPPERCASE","example::uppercase")
req.add_input_filter("UPPERCASE")
req.add_input_filter("CONTENT_LENGTH")

req.content_type = 'text/plain'
req.write('hello',0)
return apache.OK

All up this adds the following methods to the request object:

register_input_filter()
register_output_filter()
add_input_filter()
add_output_filter()

The 'add' methods can be used to add to the filter stack either predefined f
ilters, or those registered from the handler. Those registered from the hand
ler only have a registration lifetime of that request. Multiple calls can be
 made to the 'add' methods
to chain more than one filter.


> Implement req.add_output_filter().
> ----------------------------------
>
>          Key: MODPYTHON-103
>          URL: http://issues.apache.org/jira/browse/MODPYTHON-103
>      Project: mod_python
>         Type: New Feature
>   Components: core
>     Reporter: Graham Dumpleton
>      Fix For: 3.3
>  Attachments: grahamd_20060108_1_requestobject.c.diff, grahamd_20060108_2_
multiple.diff
>
> Add new member function to request object called "add_output_filter()". This would
 be a wrapper around the function "ap_add_output_filter()" and allow previously defi
ned filters to be attached to the current request such that output can be filtered t
hro
ugh them. For example:
>   req.add_output_filter("INCLUDES")
> It would probably be necessary for any such call to be done prior to the f
irst output being generated from the request handler.
> In addition to this member function, it may be necessary to also provide a
nother member function called something like "req.add_python_output_filter()
". This would be called something like:
>   req.add_python_output_filter("module_name::filter_name",path)
> Ie., like "req.add_handler()" but no first argument for phase.
> This method would allow a specific Python filter handler function to be sp
ecified. This would be equivalent to using the PythonOutputFilter directive 
to first name a mod_python based filter handler function and then adding it 
as an output filter.
>   # Main Apache config.
>   PythonOutputFilter module_name::filter_name MYFILTER
>   # Handler code.
>   req.add_output_filter("MYFILTER")
> Note that the PythonOutputFilter directive can only be used in the main Apache con
figuration file, it cannot be used in a .htaccess file. Whether it could be made to 
work in a .htaccess file in some way needs to be investigated. In mod_perl their equ
ivl
ent seems to allow it.






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 12:41 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