[Twisted-Python] serving up a directory

Jp Calderone exarkun at intarweb.us
Sun Feb 23 00:08:33 EST 2003

On Sun, Feb 23, 2003 at 04:57:38AM +0000, Clark C. Evans wrote:
> On Sun, Feb 23, 2003 at 03:57:15AM +0000, Clark C. Evans wrote:
> | root = Resource()
> | root.putChild("dynamic",MyDynamicRequest())
> | root.putChild("static",StaticRequest("/var/htdocs"))
> Err, I just needed...
>    class StaticRequest(static.File): pass
> Quite clean, and works exactly as I expected.  Kudos.
> I wouldn't have asked the question if the comment of
> this class didn't use "file" in the singular in the
> docstring.  It could say:
>     This request handler serves up a path, including
>     the Directory and Files found recursively under it.
> I'd also re-name the class "static.Path" as it really
> isn't _just_ a file resource -- it serves up directories
> too.
> Thanks tons.
> Clark
> P.S.  Is there a clear example (not using taps) of having
> both an SMTP and a HTTP server in one process?  Thanks!

  Taps are YAY!  But without one, it's really no more difficult than having
just an HTTP server:

    app = Application("whatever")
    app.listenTCP(port, siteInstance)
    app.listenTCP(anotherPot, smtpServerFactory)

  You can have practically as many listen or connect calls on the app object
as you like.  If you need more concrete examples of how to get
"smtpServerFactory", check out twisted.mail.tap.


   Know what I pray for? The strength to change what I can, the inability to
accept what I can't and the incapacity to tell the difference.    -- Calvin
 up 14 days, 8:29, 4 users, load average: 0.00, 0.00, 0.00
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20030223/a99331f9/attachment.pgp 

More information about the Twisted-Python mailing list