Integrate xmpppy with django

38 views
Skip to first unread message

est

unread,
Oct 10, 2007, 4:43:02 AM10/10/07
to Django users
Hi, all

I am writing a GoogleTalk bot for my django site, but I don't know
were to initiate a xmpppy Client object in Django. Should I put it in
my project's __init__.py ? I need the bot to be always online so where
can I write a GLOBAL, long survival object in Django? How can I make
xmpppy Client login only ONCE where django project starts?(I found
that __init__.py will be called several times during Django starting.)

Any info is appreciated, thank you all!

Christoph Rauch

unread,
Oct 10, 2007, 5:23:24 AM10/10/07
to Django users
est schrieb:

> I am writing a GoogleTalk bot for my django site, but I don't know
> were to initiate a xmpppy Client object in Django. Should I put it in
> my project's __init__.py ? I need the bot to be always online so where
> can I write a GLOBAL, long survival object in Django? How can I make
I wouldn't put it into __init__.py

Not knowing xmpppy, this may or may not be simple:

I would build a seperate daemon and send commands to it from inside
your Django project. If you need the other way round, just import the
required models in your xmpp client and put some logic there.

That way you can just fire off commands to the daemon without having
to worry about your connection. It's up to the daemon then.

You can start the daemon completely separate of your webserver/Django
project. Just make sure that Django can connect to the daemon, e.g.
via unix domain sockets. Domain sockets are great, because you can
restrict access to it with basic filesystem rights.

Christoph

est

unread,
Oct 10, 2007, 5:56:08 AM10/10/07
to Django users
Thank you Christoph.

Yes I have tried a independent daemon, but that's a bit complicated
for a small site. Is there a simipler way?

Simple is better.

Jarek Zgoda

unread,
Oct 10, 2007, 5:59:44 AM10/10/07
to Django users
If you insist on integratin Jabber/XMPP into your site, I'd suggest
*NOT USING* xmpppy. This library is flawed in many ways and do not
conform many standards published in XMPP RFC. Use pyxmpp (http://
pyxmpp.jajcus.net/) instead. It is written by a member of Jabber board
and is more compatible with official XMPP standard.

est

unread,
Oct 10, 2007, 7:37:49 AM10/10/07
to Django users
Many thanks for you suggestion. But you see I am currently having
problem with integration, not XMPP.

I'll consider switch to pyxmpp when the integration is done.

> > Any info is appreciated, thank you all!- Hide quoted text -
>
> - Show quoted text -

Malcolm Tredinnick

unread,
Oct 10, 2007, 9:02:47 AM10/10/07
to django...@googlegroups.com
On Wed, 2007-10-10 at 02:56 -0700, est wrote:
> Thank you Christoph.
>
> Yes I have tried a independent daemon, but that's a bit complicated
> for a small site. Is there a simipler way?

There is no guarantee that any Django process is going to be long
running or only called once -- there will be repeated imports and
restarts over the lifetime of the server. Both of these things mean that
trying to control a single long-running process from something that runs
as a response to Django imports or a request is going to have design
problems.

So you are trying to solve your problem in a way that is going to have a
lot of problems in the future. Django handles the request/response
driven side of your website or application. Long running processes,
scheduled processes, offline processes -- all of these things should be
managed separately, often via a daemon as suggested earlier. Trying to
force control into Django really is going to be more pain that it's
worth.

Regards,
Malcolm


Jarek Zgoda

unread,
Oct 11, 2007, 3:34:33 AM10/11/07
to Django users
This is the simplest (and for me - obvious) way of doing such things.
I see 2 possiblities: either write it as a "long-running", traditional
daemon (if you do not have your own XMPP server) or as Jabber/XMPP
server component. The former is simpler, the later gives you more
flexibility and seems more stable (only one point of failure).
You can always ask assistance on PyXMPP mailing list if you have any
questions, I am sure Jacek Konieczny will help you with Jabber/XMPP
issues.

est

unread,
Oct 11, 2007, 11:05:29 PM10/11/07
to Django users
Thank you all, I will try a daemon :)

> > > Christoph- Hide quoted text -

Reply all
Reply to author
Forward
0 new messages