Fwd: [mod_python] other file than .py

elekis elekis at gmail.com
Sun Jun 25 17:02:56 EDT 2006


a in fact I always has a 500 error.


so there here all file.

.htaccess (thanks Dumpleton)
-----------------------------------------------------------

AddHandler mod_python .py
PythonHandler mod_python.publisher
PythonDebug On

<Files *.pyc>
deny from all
</Files>

Options +MultiViews
MultiviewsMatch Handlers

AddType text/html;qs=1.0 .py
AddType text/html;qs=0.9 .html
AddType text/plain;qs=0.8 .txt

DirectoryIndex index.py


-----------------------------------
there is my add_event.py

def index(req):
	s = """
		<html>
			<head>
			<link rel="stylesheet" type= "text/css" href="./add_event.css">
			</head>	
			<body>
			<div>ceci est un div</div>"""
	return s + """<h6>Ici H6 est le s&eacute;lecteur de ce paragraphe en vert :
			Enfin un gain de poids non n&eacu44444444444444444444te;gligeable est souvent
			obtenu par ce langage, bien que le d&eacute;tail du contenu soit $
			aussi un &eacute;l&eacute;ment qui va plus ou moins modifier ce gain. </h6>
			</body>
			</html>
			"""

-------------------------------------------------------------

and there is  the directory tag in the apache2.conf

<Directory /var/www/public_html>
        AllowOverride FileInfo AuthConfig Limit
        Options Indexes SymLinksIfOwnerMatch IncludesNoExec
</Directory>
-----------------------------------------------------------------------
I trie with this adress (the public_html is a simple directory it's just for me

http://localhost/public_html/add_event

thanks a lot




---------- Forwarded message ----------
From: elekis <elekis at gmail.com>
Date: Jun 20, 2006 8:41 AM
Subject: Re: [mod_python] other file than .py
To: Graham Dumpleton <grahamd at dscpl.com.au>


thanks a lot


On 6/20/06, Graham Dumpleton <grahamd at dscpl.com.au> wrote:
> elekis wrote ..
> > hi,
> >
> > I continue my little way in the magic world of python script under web
> > and after installeing, testing and begin really to program a
> > interractive site , I confronted with a little problem. I cannot touch
> > other file than .py
> >
> > exemple. there is my .htaccess
> >
> > ----------------------------------
> > SetHandler mod_python
> > PythonHandler mod_python.publisher
> > PythonDebug On
> > ----------------------------------
> >
> >
> > here is my event.css
> >
> > --------------------------------
> > h6 { font-size: 50pt ; }
> > -------------------------------
> > but when he trie to load the event.css I have a 500 error
> >
> > -->http://localhost/public_html/add_event.css and it's the same thing
> > for other file. is there a thing than I must put on my htacces???
>
> Use "AddHandler" instead of "SetHandler" directive. For example:
>
>   AddHandler mod_python .py
>   PythonHandler mod_python.publisher
>
> What this says is that only requests with a .py in URL will be routed
> through to mod_python.publisher and not every request in that
> directory. This will allow you to place .css, .html, .jpg, .gif, etc files
> in the same directory.
>
> Depending on which version of mod_python you are using, you should
> also use:
>
>   <Files *.pyc>
>   deny from all
>   </Files>
>
> For older versions of mod_python this will ensure that compiled Python
> byte code files are not downloadable. In mod_python 3.2.X these byte
> code files are no longer generated for mod_python.publisher but can
> for basic handlers, but still good to use it regardless.
>
> > other thing. I very like the publisher mod.  cause we
> > http://localhost/public_html/balbla/ link (and that 's cool.
>
> If you are talking about the ability to not have .py in the URL, ie the
> multiviews feature of Apache, then you also need to include additional
> configuration to get it to work when using the AddHandler directive.
> These additional directives are:
>
>   Options +MultiViews
>   MultiviewsMatch Handlers
>
>   AddType text/html;qs=1.0 .py
>   AddType text/html;qs=0.9 .html
>   AddType text/plain;qs=0.8 .txt
>
> If you don't have this, you will find that you can't leave off the .py
> in the URL. Note that you may have to have Apache 2.0 and most
> recent version of mod_python (3.2.X) for this all to work properly.
>
> One last issue with using "AddHandler" over "SetHandler". When
> using "SetHandler", mod_python.publisher will automatically map
> a request against a directory to the 'index.py' file in the directory.
> When using "AddHandler" this will not happen by default. If you
> want this to happen, you must also include:
>
>   DirectoryIndex index.py
>
> This will cause Apache to take 'index.py' as a candidate index
> directory when request is against the directory.
>
> In summary, use the configuration:
>
>   AddHandler mod_python .py
>   PythonHandler mod_python.publisher
>   PythonDebug On
>
>   <Files *.pyc>
>   deny from all
>   </Files>
>
>   Options +MultiViews
>   MultiviewsMatch Handlers
>
>   AddType text/html;qs=1.0 .py
>   AddType text/html;qs=0.9 .html
>   AddType text/plain;qs=0.8 .txt
>
>   DirectoryIndex index.py
>
> > but on modpython.org they say that is not the fastest way.
> >
> >  Standard CGI:               23 requests/s
> >     Mod_python cgihandler:     385 requests/s
> >     Mod_python publisher:      476 requests/s
> >     Mod_python handler:       1203 requests/s
> >
> > is it possible to have the publisher link mod and the handler request???
>
> Both mod_python.publisher and mod_python.cgihandler are merely
> instances of mod_python handlers. There are slower because of the
> extra work they do on top of the basic handler interface.
>
> I would suggest you don't worry about speed issues, most sites do not need
> to be blindingly fast and you are probably going to have enough to contend
> with as it is, plus find it fast enough anyway.
>
> FWIW, those figures were probably based on really old hardware as well
> and can be ignored due to that fact. New hardware should perform much
> better.
>
> Graham
>


--
---------------------------------------------------------
nom : Jabon
prenom : Julien
matricule ulb :035890-72
---------------------------------------------------------


-- 
---------------------------------------------------------
nom : Jabon
prenom : Julien
matricule ulb :035890-72
---------------------------------------------------------


More information about the Mod_python mailing list