[Twisted-web] Re: How to configure quixote rtl?
Craig H. Anderson
craig at coot.net
Fri Jun 11 09:06:14 MDT 2004
If I read just a little further on
http://twistedmatrix.com/documents/current/howto/using-twistedweb
I see the examples I need. In my case I will be processing xxx.rtl files.
Modifying File Resources
File resources, be they root object or children thereof, have two important
attributes that often need to be modified: indexNames and processors.
indexNames determines which files are treated as index files -- served up
when a directory is rendered. processors determine how certain file
extensions are treated.
Here is an example for both, creating a site where all .rpy extensions are
Resource Scripts, and which renders directories by searching for a index.rpy
file.
from twisted.application import internet, service
from twisted.web import static, server, script
root = static.File("/var/www/htdocs")
root.indexNames=['index.rpy']
root.processors = {'.rpy': script.ResourceScript}
application = service.Application('web')
sc = service.IServiceCollection(application)
site = server.Site(root)
i = internet.TCPServer(80, site)
i.setServiceParent(sc)
File objects also have a method called ignoreExt. This method can be used to
give extension-less URLs to users, so that implementation is hidden. Here is
an example:
from twisted.application import internet, service
from twisted.web import static, server, script
root = static.File("/var/www/htdocs")
root.ignoreExt(".rpy")
root.processors = {'.rpy': script.ResourceScript}
application = service.Application('web')
sc = service.IServiceCollection(application)
site = server.Site(root)
i = internet.TCPServer(80, site)
i.setServiceParent(sc)
Now, a URL such as /foo might be served from a Resource Script called
foo.rpy, if no file by the name of foo exists.
Craig H. Anderson writes:
>
> Greetings,
>
> I would like to do some custom configuration and setup
> ResourceTemplate handling of xxx.rtl files. I'm thinking
> I can modify the following code to add the ResourceTemplate
> handling. I will be working on this today and will post
> what I find and check for any advice you may have.
>
>
> http://twistedmatrix.com/documents/current/howto/using-twistedweb
> Advanced Configuration
> Non-trivial configurations of Twisted Web are achieved
> with Python configuration files.
> #---------------------------------------
> from twisted.application import internet, service
> from twisted.web import static, server
>
> root = static.File("/var/www/htdocs")
> application = service.Application('web')
> site = server.Site(root)
> sc = service.IServiceCollection(application)
> i = internet.TCPServer(80, site)
> i.setServiceParent(sc)
>
>
> _______________________________________________
> Twisted-web mailing list
> Twisted-web at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
>
More information about the Twisted-web
mailing list