By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,310 Members | 1,466 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,310 IT Pros & Developers. It's quick & easy.

Event-driven framework (other than Twisted)?

P: n/a
Are there any python event driven frameworks other than twisted?
Oct 1 '08 #1
Share this Question
Share on Google+
15 Replies


P: n/a
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).

Oct 1 '08 #2

P: n/a
On Oct 1, 9:25*am, Lie Ryan <lie.1...@gmail.comwrote:
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.
Oct 1 '08 #3

P: n/a
Phillip B Oldham schrieb:
On Oct 1, 9:25 am, Lie Ryan <lie.1...@gmail.comwrote:
>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.
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
Oct 1 '08 #4

P: n/a
On Oct 1, 4:12*pm, Thomas Guettler <h...@tbz-pariv.dewrote:
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).
Oct 1 '08 #5

P: n/a
Phillip B Oldham a écrit :
On Oct 1, 4:12 pm, Thomas Guettler <h...@tbz-pariv.dewrote:
>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).
"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.
Oct 1 '08 #6

P: n/a
On Wed, 01 Oct 2008 18:09:20 +0200, Bruno Desthuilliers wrote:
Phillip B Oldham a écrit :
>On Oct 1, 4:12 pm, Thomas Guettler <h...@tbz-pariv.dewrote:
>>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).

"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.
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.

Oct 1 '08 #7

P: n/a
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 <jk******@ltgc.com>
Land Title Guarantee Company

Oct 1 '08 #8

P: n/a
On Oct 1, 6:53*pm, Lie Ryan <lie.1...@gmail.comwrote:
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?
Oct 1 '08 #9

P: n/a
On Wed, Oct 1, 2008 at 6:01 PM, Phillip B Oldham
<ph************@gmail.comwrote:
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"
Oct 2 '08 #10

P: n/a
On Wed, Oct 1, 2008 at 6:55 PM, Phillip B Oldham
<ph************@gmail.comwrote:
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....ellopymills.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.

cheers
James

--
--
-- "Problems are solved by method"
Oct 2 '08 #11

P: n/a
On Thu, Oct 2, 2008 at 2:09 AM, Bruno Desthuilliers
<br********************@websiteburo.invalidwrote :
"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.

cheers
James

--
--
-- "Problems are solved by method"
Oct 2 '08 #12

P: n/a
On Oct 2, 1:32*am, "James Mills" <prolo...@shortcircuit.net.auwrote:
http://hg.shortcircuit.net.au/index....7498cd4c6a4/ex...
Thanks for the example, but its not loading.
Oct 2 '08 #13

P: n/a
On Oct 2, 1:28*am, "James Mills" <prolo...@shortcircuit.net.auwrote:
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.
Oct 2 '08 #14

P: n/a
On 10/2/08, Phillip B Oldham <ph************@gmail.comwrote:
On Oct 2, 1:28 am, "James Mills" <prolo...@shortcircuit.net.auwrote:
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.
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 :)

Thanks,

cheers
James

--
--
-- "Problems are solved by method"
Oct 3 '08 #15

P: n/a
On 10/2/08, Phillip B Oldham <ph************@gmail.comwrote:
On Oct 2, 1:32 am, "James Mills" <prolo...@shortcircuit.net.auwrote:
http://hg.shortcircuit.net.au/index....7498cd4c6a4/ex...

Thanks for the example, but its not loading.
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>

--
--
-- "Problems are solved by method"
Oct 3 '08 #16

This discussion thread is closed

Replies have been disabled for this discussion.