[mod_python] Problem getting the Publisher handler to return nothing

Graham Dumpleton graham.dumpleton at gmail.com
Mon Jan 28 19:19:36 EST 2008


Then the content type can't be getting sent back properly.

Under FireFox use live headers extension to see what headers are
actually being returned.

Make sure nothing has cached your page and thus a set of old headers.

BTW, is there any reason why you cant use just:

def launch(req):
   req.content_type = 'text/plain'
   return ''

Graham

On 29/01/2008, Charles Collis <charles.collis at gmail.com> wrote:
> Thanks Graham.
>
> No I don't have any associated applications for .py files with my browser(s)
> - I have checked the list of applications in Firefox preferences (on Ubuntu
> machine) also this behaviour is happens on my Mac using Safari...
>
> Seems a bit odd!
>
>
> On Jan 28, 2008 5:58 AM, Graham Dumpleton <graham.dumpleton at gmail.com>
> wrote:
> > That might be the case if you have through the browser associated the
> > .py extension with some helper application for opening it. In other
> > words, nothing to do with mod_python but your personal machine, or at
> > least the browsers you are using. Try ensuring that any knowledge
> > within browser configuration for .py extension is cleared.
> >
> >
> >
> >
> > Graham
> >
> > On 28/01/2008, Charles Collis <charles.collis at gmail.com> wrote:
> > > Thanks Graham.
> > >
> > > It now works as intended, although only with Konqueror - Firefox and
> Safari
> > > both blank the page and the URL in address bar goes to
> > > http://localhost/python/launch, rather than staying at the page they
> were on
> > > before. Here is the new code as suggested:
> > >
> > > def launch(req):
> > >    req.content_type = 'text/plain'
> > >    raise apache.SERVER_RETURN, apache.OK
> > >
> > > The only other way I have been able to get it to simulate not leaving
> the
> > > current page is by returning a short bit of html containing some
> javascript
> > > that automatically goes back one page (from the new blank page) - but
> this
> > > is pretty ugly!
> > >
> > >
> > > On Jan 27, 2008 9:12 PM, Graham Dumpleton <graham.dumpleton at gmail.com>
> > > wrote:
> > > > You still must set the response content type else the browser tries to
> > > > work out what to do based on the extension in the URL. So, use:
> > > >
> > > >  req.content_type = 'text/plain'
> > > >
> > > > Graham
> > > >
> > > >
> > > >
> > > >
> > > > On 28/01/2008, Charles Collis <charles.collis at gmail.com> wrote:
> > > > > Hi.
> > > > >
> > > > > I wonder if anyone can help - I am having problems getting the
> Publisher
> > > > > handler to return nothing.
> > > > >
> > > > > I am wanting the publisher handler to return nothing when clicking
> on a
> > > link
> > > > > that points to a particular function which will perform a system
> > > command,
> > > > > and I am using the recommended 'raise apache.SERVER_RETURN,
> apache.OK'
> > > > > trick.
> > > > >
> > > > > This does indeed stop the page contents refreshing, but has the odd
> > > > > side-effect of the browser asking wanting to download a file (of
> 'python
> > > > > script' type). This behaviour happens in both Firefox 3 beta2 and
> > > Konqueror.
> > > > > It even does it if the function doesn't do anything:
> > > > >
> > > > > def launch():
> > > > >    pass
> > > > >    raise apache.SERVER_RETURN, apache.OK
> > > > >
> > > > > I am running Ubuntu Gutsy.
> > > > >
> > > > > Apache and mod_python details:
> > > > > Apache/2.2.4 (Ubuntu) mod_python/3.3.1 Python/2.5.1
> PHP/5.2.3-1ubuntu6.3
> > > > >
> > > > > Any pointers appreciated. Thanks.
> > > > >
> > > > > Charles Collis.
> > > > >
> > > > > _______________________________________________
> > > > > 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