[Twisted-Python] irc server run by twisted and (probably) django

Hi, I am new to twisted - so I am not very into it yet. I want to create a IRC Server that reacts a little bit different compared to others: * only registered users will be able to /list channels and /join them. * /list only returns channels the user registered * /join is only apply-able on those channels, too * /join new-channel won't work * Registering and channel-creation is done not in IRC but in a website, probably driven by django. Any comment on this is welcomed * where should I start? * readings? * examples? * existing similar projects? Thanks, Manuel

On Tue, 14 Oct 2008 16:13:20 +0300, Manuel Meyer <manuel@vikingosegundo.de> wrote:
Twisted includes an implementation of the IRC server protocol. It's fairly basic, so it probably will only save you from having to find line delimiters and split up IRC commands into tokens. Twisted Words includes a user/group model, but it's not quite the one you described. It might be useful for you to take a look at it, but I don't know if any of the code will be re-usable. The good news is that nothing in the IRC server protocol implementation will prevent you from implementing the user/group model you described above. You can find most of the implementation of the existing IRC server here: http://twistedmatrix.com/trac/browser/trunk/twisted/words/service.py There's not really any documentation for it aside from the docstrings. You can run the server it implements using `twistd words [options]´. Jean-Paul

OoO En ce début d'après-midi ensoleillé du mardi 14 octobre 2008, vers 15:13, Manuel Meyer <manuel@vikingosegundo.de> disait :
Using Twisted Web or Nevow will allow to tightly integrate your application and the web server. The "event loop" of Django is not compatible with Twisted reactor. You will need some extra stuff to make your Django application communicate with your IRC server. One way would be to just use the database. -- I WILL NOT TEACH OTHERS TO FLY I WILL NOT TEACH OTHERS TO FLY I WILL NOT TEACH OTHERS TO FLY -+- Bart Simpson on chalkboard in episode 9F05

I expected that. But I am already using django in several projects and heard yesterday the first time of nevow and t-web. I thought of writing a standalone IRCServer and connect to the db of django - actually I have this part already working. and with the manager of django But I don't know how to inform IRCServer about changes in the site/db. Maybe by adding another network protocol to the twisted application, where django's signals could leave a note? Manuel Am 14.10.2008 um 19:13 schrieb Vincent Bernat:

On Oct 16, 2008, at 4:26 PM, Manuel Meyer wrote:
I may be missing something, but if you keep all your data in the DB, there's no need to notify the irc server of changes to the DB. The only time you'll need this user information (it seems) is while responding to /join and /list requests. Just read the DB at that time. What's nice about this is the DB takes care of most if not all of your synchronization requirements, so you have far fewer concurrency issues to think about than if you were broadcasting changes from the web app to the irc server. -phil

I've done a similar type project but with a mailserver built using twisted.mail. I used django.contrib.admin to help manage the db for the mailserver config. From the mailservers, I was able to get by with 5 min Looping Calls to the database to build the required config data and just cached the data until the next successful db call . While not entirely applicable to your problem, I wanted to bring it up because of the slightly different choice I made on how to gather data out of the database. As the previous poster mentioned, I didn't want to mess around with concurrency and decided that my mailservers (2 of them now) would not care about each other and just get their config data out of the database. Where I also differ is I couldn't afford a sql query per each connections MAIL FROM or RCPT TO. So I had to make it slightly more flexible while still meeting the requirement of a database stored config. I basically choose a delayed Pull approach. One upshot is I coded the sql calls so that the config data survives a database failure and just keeps working with it's previous data grab. I also coded a twisted.web service administration page that allows for a manual reload of the data on the individual server if an emergency came up and I absolutely needed the config to change. It's a different flavor you can use if you know your data is fairly static and the number of people changing the data is low. Now back to your problem... I've also used the spread toolkit before (no not the twisted.spread.. and yes... OSS name collision). If I were writing such an app, and thought I'd be using a number of servers for the service; I'd consider using spread to keep things the same on all servers and for anything else I needed quickly. You'd still want a database, you just aren't always using sql to pull data that you need. You are using the spread bus and your IRC twisted app (more likely a service within your twisted app) is just listening for the data that you deem high priority. Commonly referred to as a Push approach. http://www.spread.org Someone out there has done some work with spread and twisted. I don't know how well the code works. As for django, it'd be pretty easy to send a spread message. http://anarkystic.com/devdev/spreader-intro Hope you get some ideas. -rob On Thu, Oct 16, 2008 at 1:56 PM, Phil Christensen <phil@bubblehouse.org> wrote:

I couldn't come online for quite awhile.... No, you didnt miss anything, I missed to explain new thoughts I came up with: If the irc server is already connected with the django site, why not offer users the possibility of chatting via js-powered chat like in facebook. But therefor the irc server must be informed somehow. Manuel

On Tue, 14 Oct 2008 16:13:20 +0300, Manuel Meyer <manuel@vikingosegundo.de> wrote:
Twisted includes an implementation of the IRC server protocol. It's fairly basic, so it probably will only save you from having to find line delimiters and split up IRC commands into tokens. Twisted Words includes a user/group model, but it's not quite the one you described. It might be useful for you to take a look at it, but I don't know if any of the code will be re-usable. The good news is that nothing in the IRC server protocol implementation will prevent you from implementing the user/group model you described above. You can find most of the implementation of the existing IRC server here: http://twistedmatrix.com/trac/browser/trunk/twisted/words/service.py There's not really any documentation for it aside from the docstrings. You can run the server it implements using `twistd words [options]´. Jean-Paul

OoO En ce début d'après-midi ensoleillé du mardi 14 octobre 2008, vers 15:13, Manuel Meyer <manuel@vikingosegundo.de> disait :
Using Twisted Web or Nevow will allow to tightly integrate your application and the web server. The "event loop" of Django is not compatible with Twisted reactor. You will need some extra stuff to make your Django application communicate with your IRC server. One way would be to just use the database. -- I WILL NOT TEACH OTHERS TO FLY I WILL NOT TEACH OTHERS TO FLY I WILL NOT TEACH OTHERS TO FLY -+- Bart Simpson on chalkboard in episode 9F05

I expected that. But I am already using django in several projects and heard yesterday the first time of nevow and t-web. I thought of writing a standalone IRCServer and connect to the db of django - actually I have this part already working. and with the manager of django But I don't know how to inform IRCServer about changes in the site/db. Maybe by adding another network protocol to the twisted application, where django's signals could leave a note? Manuel Am 14.10.2008 um 19:13 schrieb Vincent Bernat:

On Oct 16, 2008, at 4:26 PM, Manuel Meyer wrote:
I may be missing something, but if you keep all your data in the DB, there's no need to notify the irc server of changes to the DB. The only time you'll need this user information (it seems) is while responding to /join and /list requests. Just read the DB at that time. What's nice about this is the DB takes care of most if not all of your synchronization requirements, so you have far fewer concurrency issues to think about than if you were broadcasting changes from the web app to the irc server. -phil

I've done a similar type project but with a mailserver built using twisted.mail. I used django.contrib.admin to help manage the db for the mailserver config. From the mailservers, I was able to get by with 5 min Looping Calls to the database to build the required config data and just cached the data until the next successful db call . While not entirely applicable to your problem, I wanted to bring it up because of the slightly different choice I made on how to gather data out of the database. As the previous poster mentioned, I didn't want to mess around with concurrency and decided that my mailservers (2 of them now) would not care about each other and just get their config data out of the database. Where I also differ is I couldn't afford a sql query per each connections MAIL FROM or RCPT TO. So I had to make it slightly more flexible while still meeting the requirement of a database stored config. I basically choose a delayed Pull approach. One upshot is I coded the sql calls so that the config data survives a database failure and just keeps working with it's previous data grab. I also coded a twisted.web service administration page that allows for a manual reload of the data on the individual server if an emergency came up and I absolutely needed the config to change. It's a different flavor you can use if you know your data is fairly static and the number of people changing the data is low. Now back to your problem... I've also used the spread toolkit before (no not the twisted.spread.. and yes... OSS name collision). If I were writing such an app, and thought I'd be using a number of servers for the service; I'd consider using spread to keep things the same on all servers and for anything else I needed quickly. You'd still want a database, you just aren't always using sql to pull data that you need. You are using the spread bus and your IRC twisted app (more likely a service within your twisted app) is just listening for the data that you deem high priority. Commonly referred to as a Push approach. http://www.spread.org Someone out there has done some work with spread and twisted. I don't know how well the code works. As for django, it'd be pretty easy to send a spread message. http://anarkystic.com/devdev/spreader-intro Hope you get some ideas. -rob On Thu, Oct 16, 2008 at 1:56 PM, Phil Christensen <phil@bubblehouse.org> wrote:

I couldn't come online for quite awhile.... No, you didnt miss anything, I missed to explain new thoughts I came up with: If the irc server is already connected with the django site, why not offer users the possibility of chatting via js-powered chat like in facebook. But therefor the irc server must be informed somehow. Manuel
participants (5)
-
Jean-Paul Calderone
-
Manuel Meyer
-
Phil Christensen
-
Rob Hoadley
-
Vincent Bernat