# Path: bnw/xmpp/base.py
# def send_plain(dst, src, msg):
#     reactor.callFromThread(service.send_plain, dst, src, msg)
#     # instead of service.send_plain(dst,src,msg)


from bnw_mongo import get_db #, mongo_errors
from bnw.xmpp.base import send_plain
from base import notifiers, config
from tornado.concurrent import Future
from twisted.internet import defer
from tornado import gen
from tornado.ioloop import IOLoop
import time
        ((("user", 1),), False, False),
    )

    def save(self, safe=True):
        print "+COMMENT:", self.doc
        return super(Comment, self).save()

    @defer.inlineCallbacks
    def deliver(self, target, recommender=None, recocomment=None, sfrom=None):
        res = 0
        for notifier in notifiers:
            res += yield notifier.notify(target, 'comment', (self, sfrom))
        defer.returnValue(res)


class User(MongoObject):
    """ Няшка-пользователь."""
    collection = CollectionWrapper("users")
    dangerous_fields = ('_id', 'login_key', 'avatar', 'jid', 'jids',
                        'pending_jids', 'id', 'settings', 'blacklist',
                        'last_activity', )
    indexes = (
        ((("name", 1),), True, False),
        ((("last_activity", -1),), False, False),
    )

    def send_plain(self, message, sfrom=None):
        if not sfrom:
            sfrom = self.get('settings', {}).get('servicejid', None)
        if self['jid']:

# Path: bnw/xmpp/base.py
# def send_plain(dst, src, msg):
#     reactor.callFromThread(service.send_plain, dst, src, msg)
#     # instead of service.send_plain(dst,src,msg)


# Path: bnw/core/bnw_objects.py
from bnw_mongo import get_db #, mongo_errors
from bnw.xmpp.base import send_plain
from base import notifiers, config
from tornado.concurrent import Future
from twisted.internet import defer
from tornado import gen
from tornado.ioloop import IOLoop
import time

        ((("user", 1),), False, False),
    )

    def save(self, safe=True):
        print "+COMMENT:", self.doc
        return super(Comment, self).save()

    @defer.inlineCallbacks
    def deliver(self, target, recommender=None, recocomment=None, sfrom=None):
        res = 0
        for notifier in notifiers:
            res += yield notifier.notify(target, 'comment', (self, sfrom))
        defer.returnValue(res)


class User(MongoObject):
    """ Няшка-пользователь."""
    collection = CollectionWrapper("users")
    dangerous_fields = ('_id', 'login_key', 'avatar', 'jid', 'jids',
                        'pending_jids', 'id', 'settings', 'blacklist',
                        'last_activity', )
    indexes = (
        ((("name", 1),), True, False),
        ((("last_activity", -1),), False, False),
    )

    def send_plain(self, message, sfrom=None):
        if not sfrom:
            sfrom = self.get('settings', {}).get('servicejid', None)
        if self['jid']:

            send_plain(self['jid'], sfrom, message)