[PEAK] Interfacing Peak with Twisted
Phillip J. Eby
pje at telecommunity.com
Fri Mar 4 08:41:46 EST 2005
At 08:58 AM 3/4/05 -0100, Tiago Cogumbreiro wrote:
>I wanted to test the Peak framework and interface it with Twisted. One
>problem I had was that the wiki page[1] @ devcenter has a file for
>download with 0 byte length. There might be something wrong with it.
>Does someone have it so I can have a glance?
It seems to have gotten lost along the way, deleted by a Wiki spammer who
was trying to hack the website. :(
You might have a look at:
http://peakplace.tigris.org/source/browse/peakplace/src/junction/
which was a work-in-progress by John Landahl that's basically a
Twisted/PEAK messaging server. It's not nearly as simple as an example, of
course.
> The exercise I want to do
>is to extend the bulletins[2] example and add it i) a ZoDB storage ii)
>a xmlrpc frontend (using twisted) and possibly a nevow frontend too.
Well, not a lot I can help you with on those two items, except to point out
that you'll have to integrate PEAK and ZODB's transaction systems to use
ZODB. PEAK SQL drivers already integrate with PEAK's transaction system,
so they're simpler. With regard to an XML-RPC front-end, or any Twisted
front-end, it's important to note that peak.model classes and the related
peak.storage systems are synchronous, so you'll need to use a Twisted
threadpool. Also note that PEAK-defined objects generally make no attempts
to be threadsafe, so each thread will need its own PEAK configuration root
instance (PEAK's config.makeRoot()) so that they're isolated from one
another. You'll need, however, some way to share your ZODB database, but
not connections to it.
In short, you have probably picked the two most complicated things
imaginable for your first project, because just integrating ZODB and
Twisted in the same application seems complex, let alone adding another
layer (PEAK) in between them. If your goal is an XML-RPC and/or web
front-end, may I suggest you first try peak.web? peak.web is runnable with
WSGI, which means it's runnable within Twisted, albeit only in a
single-threaded manner at the moment.
peak.web doesn't have any built-in XML-RPC support yet, so you'd have to
write your methods such that they call xmlrpclib to parse the request and
generate the response, but it certainly would be a much simpler place to
start than integrating a foreign transaction system or creating a
multi-threaded PEAK application server.
I'm fairly certain there are people on this list who've done both of those
things, but I don't think they did so as their first PEAK project. :)
More information about the PEAK
mailing list