Event-driven framework (other than Twisted)?

James Mills prologic at shortcircuit.net.au
Thu Oct 2 02:28:13 CEST 2008


On Wed, Oct 1, 2008 at 6:01 PM, Phillip B Oldham
<phillip.oldham at 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"



More information about the Python-list mailing list