Some code style cleanup
darcs-hash:20070530062346-86b55-64349462a3967c5f804d6d39b59276428a15477e.gz
This commit is contained in:
@@ -695,7 +695,6 @@ class AccountManager(object):
|
|||||||
if new_account:
|
if new_account:
|
||||||
result.append(Message(\
|
result.append(Message(\
|
||||||
from_jid = self.component.jid, to_jid = _account.user_jid, \
|
from_jid = self.component.jid, to_jid = _account.user_jid, \
|
||||||
stanza_type = "normal", \
|
|
||||||
subject = _account.get_new_message_subject(lang_class), \
|
subject = _account.get_new_message_subject(lang_class), \
|
||||||
body = _account.get_new_message_body(lang_class)))
|
body = _account.get_new_message_body(lang_class)))
|
||||||
result.append(Presence(from_jid = _account.jid, \
|
result.append(Presence(from_jid = _account.jid, \
|
||||||
@@ -704,7 +703,6 @@ class AccountManager(object):
|
|||||||
else:
|
else:
|
||||||
result.append(Message(\
|
result.append(Message(\
|
||||||
from_jid = self.component.jid, to_jid = _account.user_jid, \
|
from_jid = self.component.jid, to_jid = _account.user_jid, \
|
||||||
stanza_type = "normal", \
|
|
||||||
subject = _account.get_update_message_subject(lang_class), \
|
subject = _account.get_update_message_subject(lang_class), \
|
||||||
body = _account.get_update_message_body(lang_class)))
|
body = _account.get_update_message_body(lang_class)))
|
||||||
self.db_disconnect()
|
self.db_disconnect()
|
||||||
@@ -1092,7 +1090,6 @@ class AccountManager(object):
|
|||||||
_account.waiting_password_reply = True
|
_account.waiting_password_reply = True
|
||||||
result.append(Message(from_jid = _account.jid, \
|
result.append(Message(from_jid = _account.jid, \
|
||||||
to_jid = _account.user_jid, \
|
to_jid = _account.user_jid, \
|
||||||
stanza_type = "normal", \
|
|
||||||
subject = u"[PASSWORD] " + \
|
subject = u"[PASSWORD] " + \
|
||||||
lang_class.ask_password_subject, \
|
lang_class.ask_password_subject, \
|
||||||
body = lang_class.ask_password_body % \
|
body = lang_class.ask_password_body % \
|
||||||
@@ -1201,7 +1198,6 @@ class PasswordMessageHandler(Handler):
|
|||||||
_account.waiting_password_reply = False
|
_account.waiting_password_reply = False
|
||||||
return [Message(from_jid = _account.jid, \
|
return [Message(from_jid = _account.jid, \
|
||||||
to_jid = stanza.get_from(), \
|
to_jid = stanza.get_from(), \
|
||||||
stanza_type = "normal", \
|
|
||||||
subject = lang_class.password_saved_for_session, \
|
subject = lang_class.password_saved_for_session, \
|
||||||
body = lang_class.password_saved_for_session)]
|
body = lang_class.password_saved_for_session)]
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# -*- coding: UTF-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
##
|
##
|
||||||
## component.py
|
## component.py
|
||||||
## Login : David Rousselie <dax@happycoders.org>
|
## Login : David Rousselie <dax@happycoders.org>
|
||||||
@@ -46,13 +46,13 @@ class FeederComponent(JCLComponent):
|
|||||||
port,
|
port,
|
||||||
db_connection_str,
|
db_connection_str,
|
||||||
lang = Lang()):
|
lang = Lang()):
|
||||||
JCLComponent.__init__(self, \
|
JCLComponent.__init__(self,
|
||||||
jid, \
|
jid,
|
||||||
secret, \
|
secret,
|
||||||
server, \
|
server,
|
||||||
port, \
|
port,
|
||||||
db_connection_str, \
|
db_connection_str,
|
||||||
lang = lang)
|
lang=lang)
|
||||||
# Define default feeder and sender, can be override
|
# Define default feeder and sender, can be override
|
||||||
self.feeder = Feeder(self)
|
self.feeder = Feeder(self)
|
||||||
self.sender = Sender(self)
|
self.sender = Sender(self)
|
||||||
@@ -63,8 +63,8 @@ class FeederComponent(JCLComponent):
|
|||||||
def handle_tick(self):
|
def handle_tick(self):
|
||||||
"""Implement main feed/send behavior"""
|
"""Implement main feed/send behavior"""
|
||||||
self.db_connect()
|
self.db_connect()
|
||||||
for _account in Account.select(clauseTables = ["account"], \
|
for _account in Account.select(clauseTables=["account"],
|
||||||
orderBy = "user_jid"):
|
orderBy="user_jid"):
|
||||||
for subject, body in self.feeder.feed(_account):
|
for subject, body in self.feeder.feed(_account):
|
||||||
self.sender.send(_account, subject, body)
|
self.sender.send(_account, subject, body)
|
||||||
self.db_disconnect()
|
self.db_disconnect()
|
||||||
@@ -95,21 +95,18 @@ class MessageSender(Sender):
|
|||||||
|
|
||||||
def send(self, to_account, subject, body):
|
def send(self, to_account, subject, body):
|
||||||
"""Implement abstract method from Sender class and send data as Jabber message"""
|
"""Implement abstract method from Sender class and send data as Jabber message"""
|
||||||
self.component.stream.send(Message(\
|
self.component.stream.send(Message(from_jid=to_account.jid,
|
||||||
from_jid = to_account.jid, \
|
to_jid=to_account.user_jid,
|
||||||
to_jid = to_account.user_jid, \
|
subject=subject,
|
||||||
subject = subject, \
|
body=body))
|
||||||
stanza_type = "normal", \
|
|
||||||
body = body))
|
|
||||||
|
|
||||||
class HeadlineSender(Sender):
|
class HeadlineSender(Sender):
|
||||||
"""Send data as Jabber Headline"""
|
"""Send data as Jabber Headline"""
|
||||||
|
|
||||||
def send(self, to_account, subject, body):
|
def send(self, to_account, subject, body):
|
||||||
"""Implement abstract method from Sender class and send data as Jabber headline"""
|
"""Implement abstract method from Sender class and send data as Jabber headline"""
|
||||||
self.component.stream.send(Message(\
|
self.component.stream.send(Message(from_jid=to_account.jid,
|
||||||
from_jid = to_account.jid, \
|
to_jid=to_account.user_jid,
|
||||||
to_jid = to_account.user_jid, \
|
subject=subject,
|
||||||
subject = subject, \
|
stanza_type="headline",
|
||||||
stanza_type = "headline", \
|
body=body))
|
||||||
body = body))
|
|
||||||
|
|||||||
@@ -2248,7 +2248,6 @@ class PasswordMessageHandler_TestCase(unittest.TestCase):
|
|||||||
jid = "account12@jcl.test.com")
|
jid = "account12@jcl.test.com")
|
||||||
message = Message(from_jid = "user1@test.com", \
|
message = Message(from_jid = "user1@test.com", \
|
||||||
to_jid = "account11@jcl.test.com", \
|
to_jid = "account11@jcl.test.com", \
|
||||||
stanza_type = "normal", \
|
|
||||||
subject = "[PASSWORD]", \
|
subject = "[PASSWORD]", \
|
||||||
body = "secret")
|
body = "secret")
|
||||||
accounts = self.handler.filter(message)
|
accounts = self.handler.filter(message)
|
||||||
@@ -2267,7 +2266,6 @@ class PasswordMessageHandler_TestCase(unittest.TestCase):
|
|||||||
jid = "account12@jcl.test.com")
|
jid = "account12@jcl.test.com")
|
||||||
message = Message(from_jid = "user1@test.com", \
|
message = Message(from_jid = "user1@test.com", \
|
||||||
to_jid = "account11@jcl.test.com", \
|
to_jid = "account11@jcl.test.com", \
|
||||||
stanza_type = "normal", \
|
|
||||||
subject = "[PASSWORD]", \
|
subject = "[PASSWORD]", \
|
||||||
body = "secret")
|
body = "secret")
|
||||||
accounts = self.handler.filter(message)
|
accounts = self.handler.filter(message)
|
||||||
@@ -2285,7 +2283,6 @@ class PasswordMessageHandler_TestCase(unittest.TestCase):
|
|||||||
jid = "account12@jcl.test.com")
|
jid = "account12@jcl.test.com")
|
||||||
message = Message(from_jid = "user1@test.com", \
|
message = Message(from_jid = "user1@test.com", \
|
||||||
to_jid = "account11@jcl.test.com", \
|
to_jid = "account11@jcl.test.com", \
|
||||||
stanza_type = "normal", \
|
|
||||||
subject = "[NOT GOOD MESSAGE]", \
|
subject = "[NOT GOOD MESSAGE]", \
|
||||||
body = "secret")
|
body = "secret")
|
||||||
accounts = self.handler.filter(message)
|
accounts = self.handler.filter(message)
|
||||||
@@ -2302,7 +2299,6 @@ class PasswordMessageHandler_TestCase(unittest.TestCase):
|
|||||||
jid = "account12@jcl.test.com")
|
jid = "account12@jcl.test.com")
|
||||||
message = Message(from_jid = "user1@test.com", \
|
message = Message(from_jid = "user1@test.com", \
|
||||||
to_jid = "account11@jcl.test.com", \
|
to_jid = "account11@jcl.test.com", \
|
||||||
stanza_type = "normal", \
|
|
||||||
subject = "[PASSWORD]", \
|
subject = "[PASSWORD]", \
|
||||||
body = "secret")
|
body = "secret")
|
||||||
accounts = self.handler.filter(message)
|
accounts = self.handler.filter(message)
|
||||||
@@ -2319,7 +2315,6 @@ class PasswordMessageHandler_TestCase(unittest.TestCase):
|
|||||||
jid = "account12@jcl.test.com")
|
jid = "account12@jcl.test.com")
|
||||||
message = Message(from_jid = "user1@test.com", \
|
message = Message(from_jid = "user1@test.com", \
|
||||||
to_jid = "account11@jcl.test.com", \
|
to_jid = "account11@jcl.test.com", \
|
||||||
stanza_type = "normal", \
|
|
||||||
subject = "[PASSWORD]", \
|
subject = "[PASSWORD]", \
|
||||||
body = "secret")
|
body = "secret")
|
||||||
messages = self.handler.handle(message, Lang(), [account11])
|
messages = self.handler.handle(message, Lang(), [account11])
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ class MessageSender_TestCase(unittest.TestCase):
|
|||||||
Account.createTable(ifNotExists = True)
|
Account.createTable(ifNotExists = True)
|
||||||
del account.hub.threadConnection
|
del account.hub.threadConnection
|
||||||
self.sender = MessageSender(self.comp)
|
self.sender = MessageSender(self.comp)
|
||||||
self.message_type = "normal"
|
self.message_type = None
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
account.hub.threadConnection = connectionForURI('sqlite://' + DB_URL)
|
account.hub.threadConnection = connectionForURI('sqlite://' + DB_URL)
|
||||||
|
|||||||
Reference in New Issue
Block a user