1

I'm using pyramid to build up a web site and would like to find some modules about sending messages between users accounts in my web site. I've heard that rails has some gems for that such like https://github.com/ging/mailboxer or https://github.com/pluginaweek/has_messages .

I would like to find the python one. Can anyone recommend me some python modules? Thanks!

waitingkuo
  • 89,478
  • 28
  • 112
  • 118
  • I can't find any. So I've tried that creating a new table in the database and write some easy function for adding/showing/deleting the mail by my self. – waitingkuo Sep 26 '12 at 17:43
  • Where have you looked? How have you tried to find them? – Marcin Sep 26 '12 at 18:21

2 Answers2

4

You're probably best off using an existing protocol like XMPP. For Plone (a Python CMS) for example there's a complete XMPP integration with collective.xmpp.chat providing multi-user chat and Instant Messaging between authenticated users of a Plone site (demo video).

For Pyramid you'll need to do this integration yourself [1], by running a Jabber / XMPP server (such as ejabberd) and using an existing XMPP client library for Python to communicate with it. There are plenty of XMPP libraries for Python, some of them are described in the answers to this question.

Note: Don't be scared if after looking at XMPP it looks way to complex. XMPP and its extension describe a wide variety of features related to Messaging and Presence, chat is just one of them. If you don't need the other features, simply don't implement them in your webapp.

[1] Actually, there is a Pyramid project that seems to do exactly that: seshat, written by @KirkStrauser. I haven't used it myself, but it looks very promising.

Community
  • 1
  • 1
Lukas Graf
  • 30,317
  • 8
  • 77
  • 92
-1

     No; direct communication between two individuals isn't possible in web applications because they use stateless protocols; the server does not know if the request is coming from the same person or not.
      That being said, what chat applications usually do is store the communications within a database between the 2 individuals, and use AJAX to retrieve them.
     There are already lots of chat application tutorials and 3rd party chat application packages online; you might want to check them out.

Kneel-Before-ZOD
  • 4,141
  • 1
  • 24
  • 26
  • Thanks, let me check some. By the way, can you recommend me some of them? – waitingkuo Sep 26 '12 at 17:49
  • 2
    No. If the statelessness of the protocol were the issue, and the server didn't know who requests were coming from, no webapplications would be possible – Marcin Sep 26 '12 at 18:22
  • @Marcin; unless you maintain states yourself via Sessions, Cookies, Querystrings, Database and such, the server doesn't know to whom a request belongs. – Kneel-Before-ZOD Sep 26 '12 at 18:29
  • 2
    @It'sYourFault Correct, except that it's not "yourself", there's an enormous amount of support for this in every framework. Given the things you mix in your list, I honestly doubt that you understand how this works. – Marcin Sep 26 '12 at 18:43
  • If you use a framework that allows data persistence, it's because the framework's developers built that capability into it. If you develop any application from scratch, unless you create the persistence, it's not automated. That's basically my point; do tell me if/how that is wrong. – Kneel-Before-ZOD Sep 26 '12 at 19:19