[PEAK] Interfacing Peak with Twisted

Tiago Cogumbreiro cogumbreiro at gmail.com
Tue Mar 15 05:40:45 EST 2005

On Sat, 05 Mar 2005 20:25:50 -0500, Phillip J. Eby
<pje at telecommunity.com> wrote:
> At 04:51 PM 3/4/05 -0100, Tiago Cogumbreiro wrote:
> >Peak seems to be the most advanced framework in academic terms, it has
> >a very interesting concept behind it and a very clean implementation.
> >Yet it provides a number of technologies that I've never used before:
> >ini files for configuration of your components, the way of starting
> >your server (something about AbstractCommand).
> Have you looked at the IntroToPeak tutorial on the Wiki?  It teaches you
> everything you should need to know to e.g. run the bulletins example or
> create command-line applications.
I'm sorry for the late reply, but I've been busy with school and I
wanted to reply only when I had read PeakIntro. It's an excelent
document! Now I understand why bulletins works the way it does :)

> >  I've already understood
> >(in theory) the concept behind adpative programming and component
> >based programming but making the transition from that to an actual
> >example is a really big step because of the lack of documentation.
> >Where can I learn about these details?
> That depends a lot on what specifically you want to learn.  Most people
> using PEAK right now are folks who've invested some time in reading the
> source and experimenting, and then in some cases volunteered to write
> documentation.  IntroToPeak and the peak.web sample on the Wiki are both
> instances of such contributions.

In what terms does PEAK take advantage of AOP, since it has it's roots
in TransWarp. I've read a chunk about AOP but have yet failed to
understand it's pratical usage. Usually because the examples are about
logging and profilling. One thing that I find most interesting in this
framework is the theory behind it and a chance to see a real working
example of it. For example one thing that it confuses me is that most
AOP frameworks take advantage of method matching and context  of where
they are called. TransWarp and PEAK use a completly different
approach, where's the catch? I'm sorry if I misunderstood anything
about PEAK or TransWarp.

> >However twisted already provides a vast array of types of servers and
> >a simple framework to do it. So this is why I've chosen to use twisted
> >in the connectivity part and peak in the logic part.
> Sure.  PEAK doesn't attempt to duplicate Twisted, only to integrate with
> it.  Essentially, if you use a component in a PEAK application that relies
> on running.ITwistedReactor, it will end up referring to Twisted's reactor
> instead of PEAK's relatively simple one.  You can then use peak.events to
> run pseudothreads against Twisted "deferreds", etc.
> However, for a simple web application (even with XML-RPC), it's unlikely
> you'll need this level of integration, and the WSGI interface is probably
> quite sufficient, or even superior to using Twisted, as it can allow you to
> take advantage of a multiprocessor system for scaling.
I see... When I first asked about interfacing PEAK with Twisted was
basically to use PEAK's components infrastucture and Twisted's
networking capabilities, however I now understand, as you propose, to
stick to one platform.

> > > peak.web is runnable with
> > > WSGI, which means it's runnable within Twisted, albeit only in a
> > > single-threaded manner at the moment.
> >What is WSGI?
> WSGI is the Python Web Server Gateway Interface, an API for connecting web
> applications written in Python to web servers.  It is defined by PEP 333.
> There are WSGI gateways for mod_python, Twisted, and CGI out there, and
> PEAK has FastCGI and local HTTP WSGI gateways available as well.  An
> application written to the WSGI spec, or written to a framework (like
> peak.web or Zope 3) that supports WSGI, can potentially be run in any
> WSGI-supporting web server.
> This is useful because for example the "peak launch" command will launch an
> arbitrary WSGI-based application in a private web server and start your
> browser pointing to it.  This is often a nice way to develop, test, and
> debug an application that you're working on.  Once the application works as
> you want it to, you can always deploy it in another WSGI-supporting web
> server (such as Twisted).
> >Is PyProtocol used in Peak too? I've already installed Peak, I don't
> >need to install PyProtocols too, right?
> No; PEAK always includes the latest PyProtocols.  By the way, make sure
> you're using the CVS version of PEAK; there hasn't been a source or binary
> snapshot release in some time.  (I should probably create an automated
> nightly build.)
Will do.

Oh, and thank you Philip for your always insightful replies!

Tiago Cogumbreiro <cogumbreiro at users.sf.net>


More information about the PEAK mailing list