[Twisted-web] Re: Thoughts on documentation, wading into Twisted, Nevow, etc.

lloyd at paisite.com lloyd at paisite.com
Mon Jul 10 10:25:35 CDT 2006


Hi Valentino,

I've consolidated your excellent suggestions below:

- IResource interface
- Virtual host setup
- User sessions
- Templating -- who needs it?
- Templating engine (nested sequences, macros, fragments, data, renderers)
- Share global state
- Using ORMs (databases)
- Authenticating web wsers
- Per-user state
- Web-server trade-offs -- Twisted vs. Apache vs. lighttpd
- Twisted in production
- Twisted security

This tentative roadmap, I'm sure, will be further developed and refined as
we go. But, for now, I think it gives us a good place to start.

Given the structure of existing adventures; e.g.

- Short, runnable code example
- Discussion of anticipated results
- Discussion of how it works -- concepts, theory, references to Twisted
docs and source
- Conclusion

...I've copied the code for Turkey's most recent adventure below. How can
we future develop this or, or start with a new code example, to best
explicate the IResource interface? References to existing documentation
would be helpful.

Meanwhile, I'll work over the next couple of days to bring my Turkey
environment back up and will update the Turkey site with the new roadmap.

Note that Duncan MacGregor has expressed interest in participating...

(Thanks, Duncan. And welcome! Please feel free to jump in. We'll need code
examples, clear, concise conceptual discussions and definitions of
technical terms, testing/debugging when we post new code, critical
editorial eyeballing.)

And Manlio Perillo and L. Daniel Burr have suggested that this series
should focus on building an application -- pastepot or CRUD (Don't know
myself what either of those are). This warrants further discussion. For my
part, I like the idea, but have the following reservations:

-- I'd like to keep the adventures as generic as possible across many
potential applications; I fear that focusing on one application may limit
our scope.

-- Different folks may have widely different levels of interest in
different applications, whereas we all need to master the basics.

-- Developing a production-ready application may get us into a bunch of
nitty-gritty stuff that doesn't have much to do with Twisted, but does
have a lot to do with good programming practice.

That said, maybe after we've covered the basics, using the example of a
good application to put it all together may be an excellent idea. I don't
think we're talking either/or here.

Also, Terry Jones has raised some very pertainent issues -- well worth
further discussion. I'l throw in my two cents in a separate post.

Best wishes,

Lloyd

PS Here's the last code example from Techno Turkey's Adventures:

Matt Goodall's Barebones Dynamic Web Server

from twisted.application import internet, service
from twisted.web import resource, server

LOGPATH = './logs/access.log'
PORT = 8080

class DynamicResource(resource.Resource):
    """A simple, dynamic resource with a name.
    """

    def __init__(self, name):
        resource.Resource.__init__(self)
        self.name = name

    def getChild(self, name, request):
        # if the child's name is '' - the empty segment - then return
        # myself.
        if name == '':
            return self
        # Return an instance of my type with the requested segment name.
        return DynamicResource(name)

    def render(self, request):
        return '<html><p>I am a Dynamic Resource. My name is
%r.</p></html>' % (self.name)

application = service.Application('web-server')
site = server.Site(DynamicResource('root'), logPath=LOGPATH)
internet.TCPServer(PORT, site).setServiceParent(application)






More information about the Twisted-web mailing list