[mod_python] How do you know if the current request is an internal redirect?

Gavin Panella gavin at premolo.com
Fri Aug 18 09:49:47 EDT 2006

> > How do you know in your handler if this is an internal redirect?
> > req.prev is set to a req object even if there was no internal
> > redirect.
> In the main request req.main is None, and in a subrequest it points back to
> the main request, so just test if it's not None.

Actually, this isn't true, for me at least. I've been doing internal 
redirections with mod_python 3.1.4 and Apache 2.0.58 on Linux and getting the 

Main request:
	req.main is None
	req.prev is None

	req.main is None
	req.prev is not None

Perhaps that's fixed in a later version, or I have misunderstood something. 
Additionally, when issuing req.internal_redirect(...), mod_rewrite does not 
think it is a subrequest either ("RewriteCond %{IS_SUBREQ} true" does not 

Cheerio, Gavin.

Premolo Sàrl
Web: http://www.premolo.com/ ; Tel: +352 26687161 ; GSM: +352 091739359
42 rue du Kiem, L-1857 Luxembourg, Grand-Duché du Luxembourg

More information about the Mod_python mailing list