[mod_python] [help]please give an input filter example ?

Gregory (Grisha) Trubetskoy grisha at modpython.org
Tue Sep 23 10:35:19 EST 2003


I've looked at the input filter code, and I think that what's in 3.0.3 is
broken. If you get the latest CVS version, your input filter code would
look somethng like:

def inputfilter(filter):

	s = filter.read()

	if s:
		## do something with s here

		filter.write(s)
	else:
		filter.close()

	return apache.OK

Note that the filter will only see the body of the POST request, it will
not see the headers, in fact it won't even be called for GET requests.

Grisha

On Fri, 19 Sep 2003, camge wrote:

> > >I need input filter to convert character set of form data submitted by
> cell
> > >phone browser.
> > >For example, convert utf-8 to big5 or gb.
> > >If I can do it in input filter, then I dont need to modify all of my
> pages.
> > >
> > >
> > Aha. What I would do is just put a function in a module that changes the
> > encoding.
> > Get the arguments like you normally would, then just do a decode/encode.
> > Since that module can be accessed from anywhere, it will work just as
> well.
> > Also, it's less likely to cause bugs, and will probably be faster
> > (you'll only making one jump into the Python interpreter and back)
> >
> > Cheers
> > David
> >
> Thanks for your suggestion!
> But my web server serve not only wap browser but also Pocket IE and IE,
> and they all use same module(for easy maintenance).
> Adding this function in these modules will be a terrible thing,
> because I dont need to convert character encoding for Pocket IE and IE.
>
> If I can do it in input filter, I don't need to modify any things in
> original module.
>
> regards,
> camge
>
>
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python
>


More information about the Mod_python mailing list