Twisted Documentation: The Twisted Web FAQ

# The Twisted Web FAQ

## Is the Twisted web server a toy?

No. It is a production grade server. It is running continously on several sites and has been proven quite stable. The server can take loads of up to 3000 users at a time and still keep churning several million requests a day, even on low end hardware. It can serve static files or dynamically rendered pages.

## But can Twisted Web do PHP?

Yes. It works out-of-the-box, so long as you've got the standalone php interpreter installed.

## And can Twisted Web do virtual hosting?

Can it ever!

You can decide to go with one big process for all of them, a front server and a seperate server for each virtual host (for example, for permission reasons), and you can even mix-and-match between Apache and Twisted (for example, put Apache in the front and have Twisted handle some subset of the virtual host).

## How do I use twisted.web to do complex things?

See the Twisted.Web Howto.

## I've been using Woven since before it was called Woven. I just upgraded and now I'm getting a confusing traceback talking about INodeMutator. What gives?

You probably have code that's survived the upgrade from PyXML's `minidom` to Twisted's `microdom`. Try deleting any `.pxp` files that you have lying around and the error will probably go away.

## My Woven pages are sent to the browser with a trailing slash appended to the URL, which breaks all of the relative links. How do I get rid of the trailing slash?

If you are subclassing `Page`, you can add a class attribute `addSlash = 0`, like this:

    class Foo(page.Page):
            addSlash = 0

If you are still subclassing `Controller`, you can put the `addSlash = 0` there. Consider subclassing `Page` instead, as having a `Model`, `View`, `Controller` triad as the base of a `Page` will be deprecated in the near future.

If you're just using the generic `Page` instance, you can set it after creation like this:

    resource = page.Page("foo")
    resource.addSlash = 0

The default behavior of Woven is now to automatically add a slash because it makes creating relative links far easier, ironically ;-)

## Argh! When using Woven, my newlines get mangled inside a <pre>

Use the `RawText` view.

## When trying to use Guard, I get infinite redirects to URLs with long hexadecimal numbers. What's the deal?

Are you using an RPY? Add a single line containing `cache()` as the first line of your RPY.

An RPY file is executed every time it is accessed, so the call to `guard.SessionWrapper` is executed once per request, making a new SessionWrapper for each request. There should be only one SessionWrapper object for your application. Caching the RPY file enforces this.

Index

Version: 0.6.0