[Zope3-dev] Content-types in ResourceDirectory
Jim Washington
jwashin at vt.edu
Tue Jun 20 12:53:19 EDT 2006
Jim Washington wrote:
> Still playing with Dojo. Very Nice! :)
>
> I'm having a problem with content-type for items served from a
> resourceDirectory.
>
> In particular, one piece of dojo, a file with a .html extension begins
> with <?xml version="1.0" encoding="UTF-8"?>. The DOCTYPE says XHTML 1.0
> Strict, but Zope3 returns it as text/plain (X-Content-Type-Warning:
> guessed from content).
>
> Unfortunately, that is a problem, because the client looks at
> content-type to decide how to parse.
>
> If I set the content-type to text/html, it works OK.
>
> So, is this a Dojo bug or a Zope3 bug?
>
Hearing none, the answer is:
(drumroll...)
Neither. :)
Purely static files can be served just fine through zope.paste. No need
to bother Zope 3 at all to do this.
Quick recipe:
1. install zope.paste, Paste, PasteDeploy
2. in the [Zope3 instance]/etc folder, paste.ini can look like (this
somewhat complicated example uses my gzipper as a middleware filter):
[composite:Paste.Main]
use = egg:Paste#urlmap
/ = zope3
/@@/dojo = dojo
[pipeline:zope3]
pipeline = gzipper main
[app:main]
paste.app_factory = zope.paste.application:zope_publisher_app_factory
[app:dojo]
use=egg:Paste#static
document_root=/local/filesystem/path/to/dojo/folder
filter-with = gzipper
[filter:gzipper]
paste.filter_factory=gzipper.gzipper:filter_factory
nocompress=jp gz zip
tempfile=0
exclude=test
Something similar should work for any static or third-party content.
Maybe a /static/images directory? This may be old hat to some, but I
thought I would share.
A small but important caveat: Paste.urlmap (0.9) does not seem to like
:port in urls at the moment, so no http://localhost:8180 for now. Zope3
can be listening at 8180, but you need a non-port alias for everything
to work properly. Of course, it is possible I have a local
misconfiguration somewhere that makes this break.
wsgi+zope=very cool!
-Jim Washington
More information about the Zope3-dev
mailing list