[mod_python] Questions on _call_ with mp servlets and python

Daniel Popowich dpopowich at comcast.net
Fri Sep 3 16:30:41 EDT 2004


Vinj Vinj writes:

> ...I'm trying to use _call_ but have some questions suggestions. My
> site has a yahoo like interface which has a lot of links which
> perform actions. These actions(links) go thorugh http get.
> 
> I changed the repsond so that the servlet looks for the _call_ form
> variable function gets called even if it comes from a get request.
>

I restricted the use of the _call_ mechanism to POSTs for security
reasons.  Granted, POSTs are no more secure than GETs, but at least
with POSTs you don't see the data in the URL, staring you in the
face.  And the thought calls to methods visible in the browser url
window didn't thrill me.  I've considered adding an attribute to
Servlet, say, allow_call_with_get, defaulting to false; then a
developer can set it to true if they really want to allow this
feature.  One benefit with this attribute: you can turn it on and off
per servlet instead of globally across all servlets.

Another thing you can do, to obfuscate the url string so it's not so
obvious a method is being called: change the value of METHODCALL at
the top of servlet.py.  This is probably another candidate for
turning into an attribute of Servlet.

> The second thing I would like to have is _call_
> function just be called for generating the content. So
> in effect if I subclass HTMLPage and use the _call_
> functionality my header and nav and footer functions
> don't get called. This seems strange to since almost
> every action would have to generate some content.

This functionality exists!  Check out lesson #17 of the tutorial:

    http://lnx1.blue-fox.com/~dpopowich/mpstutorial/okmethods

If a method returns True then write_html() will not be called.  So
you can have a method generate all the content and then return True.

Daniel Popowich
-----------------------------------------------
http://home.comcast.net/~d.popowich/mpservlets/
    



More information about the Mod_python mailing list