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!
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
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.
I'll consider switch to pyxmpp when the integration is done.
> > Any info is appreciated, thank you all!- Hide quoted text -
>
> - Show quoted text -
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
> > > Christoph- Hide quoted text -