Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Event-driven framework (other than Twisted)?

100 views
Skip to first unread message

Phillip B Oldham

unread,
Oct 1, 2008, 4:01:41 AM10/1/08
to
Are there any python event driven frameworks other than twisted?

Lie Ryan

unread,
Oct 1, 2008, 4:25:47 AM10/1/08
to pytho...@python.org
On Wed, 01 Oct 2008 01:01:41 -0700, Phillip B Oldham wrote:

> Are there any python event driven frameworks other than twisted?

Most GUI package use event-driven model (e.g. Tkinter).

Phillip B Oldham

unread,
Oct 1, 2008, 4:55:57 AM10/1/08
to
On Oct 1, 9:25 am, Lie Ryan <lie.1...@gmail.com> wrote:
> Most GUI package use event-driven model (e.g. Tkinter).

I've noticed that. I'm thinking more for a web environment (instead of
MVC) or as a HTTP server. I know Twisted has TwistedWeb, but I'm
looking for alternatives.

Thomas Guettler

unread,
Oct 1, 2008, 11:12:55 AM10/1/08
to
Phillip B Oldham schrieb:

Please explain what you want to do. Maybe the spread toolkit
can help you:

http://www.spread.org/index.html

HTH,
Thomas


--
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de

Phillip B Oldham

unread,
Oct 1, 2008, 11:59:25 AM10/1/08
to
On Oct 1, 4:12 pm, Thomas Guettler <h...@tbz-pariv.de> wrote:
> Please explain what you want to do.

I'm primarily looking for alternatives to MVC frameworks for web
development, particularly SAAS. I've looked around, and some
whitepapers suggest that event-based frameworks often perform better
than MVC. Since I'm looking at SAAS, having a "view" is pretty
pointless since I'll either be using Thrift, returning simple HTTP
headers, or returning some sort of JSON/YAML/XML content (possibly
based on accept headers).

Bruno Desthuilliers

unread,
Oct 1, 2008, 12:09:20 PM10/1/08
to
Phillip B Oldham a écrit :

"view" doesn't imply (x)html - any valid HTTP response is ok. The whole
point of decoupling controler from view (in web MVC) is to allow the
same controler to return different views.

Lie Ryan

unread,
Oct 1, 2008, 1:53:47 PM10/1/08
to pytho...@python.org

In fact, MVC and event-driven is two entirely different concept. You can
have both, or none. It is, in the end, your choice which one to use or
whether you want to use both or none.

Event-driven programming is a concept that your programs are entirely
composed of function definition and binding that function definition to
events. The rest is handled by a mainloop, which calls the appropriate
functions when it receives something.

MVC is a separation of concern. In MVC code you want that there is a
clear boundary between code that handles Model, View, and Controller, so
it'd be easier to manage the code.

John Krukoff

unread,
Oct 1, 2008, 2:02:31 PM10/1/08
to Phillip B Oldham, pytho...@python.org
You could take a look at this interesting looking server that popped up
on the mailing list a while back:

http://code.google.com/p/yield/

On Wed, 2008-10-01 at 01:01 -0700, Phillip B Oldham wrote:
> Are there any python event driven frameworks other than twisted?

> --
> http://mail.python.org/mailman/listinfo/python-list
--
John Krukoff <jkru...@ltgc.com>
Land Title Guarantee Company

Phillip B Oldham

unread,
Oct 1, 2008, 2:41:10 PM10/1/08
to
On Oct 1, 6:53 pm, Lie Ryan <lie.1...@gmail.com> wrote:
> In fact, MVC and event-driven is two entirely different concept. You can
> have both, or none. It is, in the end, your choice which one to use or
> whether you want to use both or none.
>
> Event-driven programming is a concept that your programs are entirely
> composed of function definition and binding that function definition to
> events. The rest is handled by a mainloop, which calls the appropriate
> functions when it receives something.
>
> MVC is a separation of concern. In MVC code you want that there is a
> clear boundary between code that handles Model, View, and Controller, so
> it'd be easier to manage the code.

So are there any other patterns that can be used in stead of MVC?

James Mills

unread,
Oct 1, 2008, 8:28:13 PM10/1/08
to Phillip B Oldham, pytho...@python.org
On Wed, Oct 1, 2008 at 6:01 PM, Phillip B Oldham
<phillip...@gmail.com> wrote:
> Are there any python event driven frameworks other than twisted?

Phillip, I have been developing a rather unique
event-driven and component architecture library
for quite some time that is (not twisted). Actually
it's nothing like twisted, but based on 2 core
concepts:
* Everything is a Component
* Everything is an Event

It's currently called pymills.event
Let me know if you're interested, I probably
plan to re-package and re-branch this library
(the event library) at some point.

Here's a small snippet showing off some of
pymills.event's features:

<code>
#!/usr/bin/env python
# -*- coding: utf-8 -*- # vim: set sw=3 sts=3 ts=3

from pymills import event
from pymills.event import *

class TodoList(Component):

todos = {}

def add(self, name, description):
assert name not in self.todos, "To-do already in list"
self.todos[name] = description
self.push(Event(name, description), "added")

class TodoPrinter(Component):

@listener("added")
def onADDED(self, name, description):
print "TODO: %s" % name
print " %s" % description

def main():
event.manager += TodoPrinter()
todo = TodoList()
event.manager += todo

todo.add("Make coffee", "Really need to make some coffee")
todo.add("Bug triage", "Double-check that all known issues were addressed")

for value in manager:
print value

if __name__ == "__main__":
main()
</code>

This example is based on a similar example provided
by the Trac project (which was also to show of it's
Component architecture).

Thanks,

cheers
James

--
--
-- "Problems are solved by method"

James Mills

unread,
Oct 1, 2008, 8:32:02 PM10/1/08
to Phillip B Oldham, pytho...@python.org
On Wed, Oct 1, 2008 at 6:55 PM, Phillip B Oldham
<phillip...@gmail.com> wrote:
> I've noticed that. I'm thinking more for a web environment (instead of
> MVC) or as a HTTP server. I know Twisted has TwistedWeb, but I'm
> looking for alternatives.

Again with pymills, here's an alternative:

http://hg.shortcircuit.net.au/index.wsgi/pymills/file/b7498cd4c6a4/examples/webtest/hellopymills.py

I have built 2 commercial web applications using my
pymills library and it's web server components (see
simple example above).

NB: I do not plan to write yet another framework :) but instead a set
of re-usable and flexible components.

James Mills

unread,
Oct 1, 2008, 8:37:29 PM10/1/08
to pytho...@python.org
On Thu, Oct 2, 2008 at 2:09 AM, Bruno Desthuilliers
<bruno.42.de...@websiteburo.invalid> wrote:
> "view" doesn't imply (x)html - any valid HTTP response is ok. The whole
> point of decoupling controler from view (in web MVC) is to allow the same
> controler to return different views.

There is an alternative to the MVC architecture, and that is to have a
set of Resources that are used by any User Interface, be on the Web,
Desktop or Console, as long as it understands HTTP (but it doesn't
have to restrict itself to the HTTP transport).

Normally the applications I build don't use your typical MVC model
or any MVC framework (as mentioned earlier, I've used pymills). I take
the CRUX/RESTful approach and build a set of resources for my
application and SaaS. Then I build a User Interface (normally I use ExtJS)j.

Phillip B Oldham

unread,
Oct 2, 2008, 3:18:50 AM10/2/08
to
On Oct 2, 1:32 am, "James Mills" <prolo...@shortcircuit.net.au> wrote:
> http://hg.shortcircuit.net.au/index.wsgi/pymills/file/b7498cd4c6a4/ex...

Thanks for the example, but its not loading.

Phillip B Oldham

unread,
Oct 2, 2008, 3:19:58 AM10/2/08
to
On Oct 2, 1:28 am, "James Mills" <prolo...@shortcircuit.net.au> wrote:
> Phillip, I have been developing a rather unique
> event-driven and component architecture library
> for quite some time that is (not twisted). Actually
> it's nothing like twisted, but based on 2 core
> concepts:
>  * Everything is a Component
>  * Everything is an Event
>
> It's currently called pymills.event
> Let me know if you're interested, I probably
> plan to re-package and re-branch this library
> (the event library) at some point.

I'd be very interested in seeing this. Component-based programming is
something which interests me also.

James Mills

unread,
Oct 2, 2008, 7:02:12 AM10/2/08
to Phillip B Oldham, pytho...@python.org

Phillip, you can normally clone my library using
Mercurial by doing:

$ hg clone http://hg.shortcircuit.net.au/pymills/

If my VPS is still down, email me and I'll send you
a tar.bz2 (or something).

It may also interest you to know that I've ported
my library to py3k and so far all tests are working :)

James Mills

unread,
Oct 2, 2008, 6:58:10 AM10/2/08
to Phillip B Oldham, pytho...@python.org

Sorry my VPS has been down for quite
some time today :/ Not happy!

Here is the sample:

<code>
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vim: set sw=3 sts=3 ts=3

import optparse

from pymills import event
from pymills.event import manager
from pymills.net.sockets import TCPServer
from pymills.event.core import listener, Component
from pymills.net.http import HTTP, Response, Dispatcher
from pymills import __version__ as systemVersion

USAGE = "%prog [options] [path]"
VERSION = "%prog v" + systemVersion

###
### Functions
###

def parse_options():
"""parse_options() -> opts, args

Parse any command-line options given returning both
the parsed options and arguments.
"""

parser = optparse.OptionParser(usage=USAGE, version=VERSION)

parser.add_option("-b", "--bind",
action="store", default="0.0.0.0:8000", dest="bind",
help="Bind to address:port")

opts, args = parser.parse_args()

return opts, args

###
### Components
###

class Test(Component):

channel = "/"

@listener("index")
def onINDEX(self, request, response):
self.send(Response(response), "response")

@listener("hello")
def onHello(self, request, response):

if request.cookie.get("seen", False):
response.body = "Seen you before!"
else:
response.body = "Hello World!"
response.cookie["seen"] = True

self.send(Response(response), "response")

@listener("test")
def onTEST(self, request, response):
response.body = "OK"
self.send(Response(response), "response")

class WebServer(TCPServer, HTTP): pass

###
### Main
###

def main():
opts, args = parse_options()

if ":" in opts.bind:
address, port = opts.bind.split(":")
port = int(port)
else:
address, port = opts.bind, 80

server = WebServer(port, address)
dispatcher = Dispatcher()

event.manager += server
event.manager += Test()
event.manager += dispatcher

while True:
try:
manager.flush()
server.poll()
except KeyboardInterrupt:
break

###
### Entry Point
###

if __name__ == "__main__":
main()
</code>

--

0 new messages