Just started playing around with CherryPy and python.
I want to serve up static content. A couple of XUL files. I set up the
staticFilter in the conf file. The file is served up however the
browser interprets it as a text file. My guess is the content-type is
incorrect. Is there anyway I could set the content-type?
Thanks in advance.
Andrew
Try this in your startup script:
from cherrypy import cptools
cptools.mimetypes.types_map['.xul'] = 'application/vnd.mozilla.xul+xml'
Robert Brewer
System Architect
Amor Ministries
fuma...@amor.org
For my installation I had to change the line
from cherrypy import cptools
to
from cherrypy.lib import cptools
for it to work.
I found this out the hard way, too, trying to serve up XHTML and atom
files with the right IMTs. I really think this is a very core and
broad need, and needs to be a .conf file option. And even better, I
think there should be a way to register an existing IMT database, such
as the conventional /etc/mime.types.
--
Uche Ogbuji Fourthought, Inc.
http://uche.ogbuji.net http://fourthought.com
http://copia.ogbuji.net http://4Suite.org
Articles: http://uche.ogbuji.net/tech/publications/
Actually, doing so is a simple matter of:
import mimetypes
mimetypes.init()
So rather than Robert's suggestion of
from cherrypy import cptools
cptools.mimetypes.types_map['.xul'] = 'application/vnd.mozilla.xul+xml'
Just do:
import mimetypes
mimetypes.init()
Which should pick up that mapping (and many others) from, say,
/etc/mime.types. If you do not have an mime.types file in a common
location, pass the file paths to check in a list to the init()
function. You might have this file somewhere even if you're on
Windows.
My question is not really CherryPy connected, but I can not ask on other
forums. But it is strongly CherryPy connected: I am using it :-)
----
If I have several programs on my web server that I want to make
accsesible to others, is there any standard way to do it?
I do not mean RPC, SOAP...
Let say: the visitors of the my web pages collects some information
from my database (using sessions); I want to allow them to call
different programs on the server with the collected data.
If I would allow access only to one program that I would 'hardcode' its
parameters into an html-form and a corresponding application/invocation.
But if I have 20 with different programs with different parameter
sets...; I also want to restrict the access of some of them for a
subnet, etc.
Basically I would create a class describing the program I want to let to
invoke, and tie the parameters, html form, and security restrictions
togeather in that class.
The QUESTION: is there any standard way, a python library to do this?
----
If I go further: in the future I want to allow clients to call the
programs directly w/o browsing the webpages...
???
In this case I do not see if the SOAP is a good direction/protocol. Or
should I build my web-page-prg-invoke class build top on RPC?
Is SOAP a widely use protocol? E.g. I could not find any "web service
registry (aka service broker)" (it could happen that I use them every
day, just I do not know... :-) )
----
If I go much further:
If the program to be invoked returns with the result in a short period
of time, I can use Pipe.
If a program makes long calculations/simulations I want to untie the
result from the session: make a tmp file from the output/result and
email the link of the result file to the requester.
Is there any library to do this? Or do I have to implement for myself?
If I implement, are there any standards to do it?
Thanks for your suggestions,
Tamas
--
Tamas Hegedus, PhD | phone: (1) 919-966 0329
UNC - Biochem & Biophys | fax: (1) 919-966 5178
5007A Thurston-Bowles Bldg | mailto:heg...@med.unc.edu
Chapel Hill, NC, 27599-7248 | http://biohegedus.org
There is no library function that can do this ...
We're building a cherrypy based bioinformatics system that does
something very similar:
Istvan.
> We're building a cherrypy based bioinformatics system that does
> something very similar:
Yes. All the bioinformatics systems collecting some data from databases
and run some programs on the result set. The usual problems are:
- they do not support what you need;
- they are not enough flexible to adjust to your need;
- or just easier and faster to implement your own solution instead of
fighting with the installation and learning of a complex system.
By the way:
- are you Hungarian? :-)
- are you work in biology?
Regards,
If you actually took the time to click the link instead of replying
you'd get answers to all of your questions.
--