xul files as static content

7 views
Skip to first unread message

avine

unread,
Jan 7, 2006, 4:10:26 PM1/7/06
to cherrypy-users
Hi,

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

Robert Brewer

unread,
Jan 7, 2006, 5:33:41 PM1/7/06
to cherryp...@googlegroups.com
avine wrote:
> 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?

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

winmail.dat

avine

unread,
Jan 8, 2006, 7:20:39 AM1/8/06
to cherrypy-users
Thanks very much.

For my installation I had to change the line
from cherrypy import cptools
to
from cherrypy.lib import cptools
for it to work.

Uche Ogbuji

unread,
Jan 8, 2006, 12:14:22 PM1/8/06
to cherrypy-users

Robert Brewer wrote:
> avine wrote:
> > 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?
>
> Try this in your startup script:
>
> from cherrypy import cptools
> cptools.mimetypes.types_map['.xul'] = 'application/vnd.mozilla.xul+xml'

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/

Uche Ogbuji

unread,
Jan 10, 2006, 2:26:01 PM1/10/06
to cherrypy-users

Uche Ogbuji wrote:
> Robert Brewer wrote:
> > avine wrote:
> > > 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?
> >
> > Try this in your startup script:
> >
> > from cherrypy import cptools
> > cptools.mimetypes.types_map['.xul'] = 'application/vnd.mozilla.xul+xml'
>
> 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.

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.

Tamas Hegedus

unread,
Jan 12, 2006, 7:06:39 PM1/12/06
to cherryp...@googlegroups.com
Hi,

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

Istvan Albert

unread,
Jan 13, 2006, 9:13:09 AM1/13/06
to cherrypy-users
> 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?

There is no library function that can do this ...

We're building a cherrypy based bioinformatics system that does
something very similar:

http://g2.bx.psu.edu


Istvan.

Tamas Hegedus

unread,
Jan 13, 2006, 9:18:37 AM1/13/06
to cherryp...@googlegroups.com
Dear 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,

Istvan Albert

unread,
Jan 13, 2006, 9:22:28 AM1/13/06
to cherrypy-users
> Yes. All the bioinformatics systems collecting some data from databases
> and run some programs on the result set. The usual problems are:

If you actually took the time to click the link instead of replying
you'd get answers to all of your questions.

Tamas Hegedus

unread,
Jan 13, 2006, 9:29:21 AM1/13/06
to cherryp...@googlegroups.com
Sorry, I checked out the galaxy in the during the time you answered...
I just missed the "we are building"...
And it is not easy to find you at PSU based on the Galaxy link. It was
easier to google...

--

Reply all
Reply to author
Forward
0 new messages