Change lang parameter to lang_class in Handlers
darcs-hash:20070605192159-86b55-7280f4eaebbebd1bb17b3e9aa29b9abff92d480b.gz
This commit is contained in:
@@ -1157,13 +1157,13 @@ class AccountManager(object):
|
|||||||
class Handler(object):
|
class Handler(object):
|
||||||
"""handling class"""
|
"""handling class"""
|
||||||
|
|
||||||
def filter(self, stanza, lang):
|
def filter(self, stanza, lang_class):
|
||||||
"""Filter account to be processed by the handler
|
"""Filter account to be processed by the handler
|
||||||
return all accounts. DB connection might already be opened."""
|
return all accounts. DB connection might already be opened."""
|
||||||
accounts = Account.select()
|
accounts = Account.select()
|
||||||
return accounts
|
return accounts
|
||||||
|
|
||||||
def handle(self, stanza, lang, accounts):
|
def handle(self, stanza, lang_class, accounts):
|
||||||
"""Apply actions to do on given accounts
|
"""Apply actions to do on given accounts
|
||||||
Do nothing by default"""
|
Do nothing by default"""
|
||||||
return []
|
return []
|
||||||
@@ -1171,7 +1171,7 @@ class Handler(object):
|
|||||||
class DefaultPresenceHandler(Handler):
|
class DefaultPresenceHandler(Handler):
|
||||||
"""Handle presence"""
|
"""Handle presence"""
|
||||||
|
|
||||||
def handle(self, presence, lang, accounts):
|
def handle(self, presence, lang_class, accounts):
|
||||||
"""Return same presence as receive one"""
|
"""Return same presence as receive one"""
|
||||||
to_jid = presence.get_to()
|
to_jid = presence.get_to()
|
||||||
from_jid = presence.get_from()
|
from_jid = presence.get_from()
|
||||||
@@ -1182,7 +1182,7 @@ class DefaultPresenceHandler(Handler):
|
|||||||
class DefaultSubscribeHandler(Handler):
|
class DefaultSubscribeHandler(Handler):
|
||||||
"""Return default response to subscribe queries"""
|
"""Return default response to subscribe queries"""
|
||||||
|
|
||||||
def handle(self, stanza, lang, accounts):
|
def handle(self, stanza, lang_class, accounts):
|
||||||
"""Create subscribe response"""
|
"""Create subscribe response"""
|
||||||
result = []
|
result = []
|
||||||
result.append(Presence(from_jid=stanza.get_to(),
|
result.append(Presence(from_jid=stanza.get_to(),
|
||||||
@@ -1196,7 +1196,7 @@ class DefaultSubscribeHandler(Handler):
|
|||||||
class DefaultUnsubscribeHandler(Handler):
|
class DefaultUnsubscribeHandler(Handler):
|
||||||
"""Return default response to subscribe queries"""
|
"""Return default response to subscribe queries"""
|
||||||
|
|
||||||
def handle(self, stanza, lang, accounts):
|
def handle(self, stanza, lang_class, accounts):
|
||||||
"""Create subscribe response"""
|
"""Create subscribe response"""
|
||||||
result = []
|
result = []
|
||||||
result.append(Presence(from_jid=stanza.get_to(),
|
result.append(Presence(from_jid=stanza.get_to(),
|
||||||
@@ -1214,7 +1214,7 @@ class PasswordMessageHandler(Handler):
|
|||||||
"""Ḧandler constructor"""
|
"""Ḧandler constructor"""
|
||||||
self.password_regexp = re.compile("\[PASSWORD\]")
|
self.password_regexp = re.compile("\[PASSWORD\]")
|
||||||
|
|
||||||
def filter(self, stanza, lang):
|
def filter(self, stanza, lang_class):
|
||||||
"""Return the uniq account associated with a name and user JID.
|
"""Return the uniq account associated with a name and user JID.
|
||||||
DB connection might already be opened."""
|
DB connection might already be opened."""
|
||||||
name = stanza.get_to().node
|
name = stanza.get_to().node
|
||||||
@@ -1234,13 +1234,13 @@ class PasswordMessageHandler(Handler):
|
|||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def handle(self, stanza, lang, accounts):
|
def handle(self, stanza, lang_class, accounts):
|
||||||
"""Receive password in stanza (must be a Message) for given account"""
|
"""Receive password in stanza (must be a Message) for given account"""
|
||||||
_account = accounts[0]
|
_account = accounts[0]
|
||||||
_account.password = stanza.get_body()
|
_account.password = stanza.get_body()
|
||||||
_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(),
|
||||||
subject = lang.password_saved_for_session, \
|
subject=lang_class.password_saved_for_session,
|
||||||
body = lang.password_saved_for_session)]
|
body=lang_class.password_saved_for_session)]
|
||||||
|
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ class LangExample(Lang):
|
|||||||
type_example_name = "Type Example"
|
type_example_name = "Type Example"
|
||||||
|
|
||||||
class TestSubscribeHandler(DefaultSubscribeHandler):
|
class TestSubscribeHandler(DefaultSubscribeHandler):
|
||||||
def filter(self, message, lang):
|
def filter(self, message, lang_class):
|
||||||
if re.compile(".*%.*").match(message.get_to().node):
|
if re.compile(".*%.*").match(message.get_to().node):
|
||||||
# return no account because self.handle does not need an account
|
# return no account because self.handle does not need an account
|
||||||
return []
|
return []
|
||||||
@@ -137,11 +137,11 @@ class TestSubscribeHandler(DefaultSubscribeHandler):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
class ErrorHandler(Handler):
|
class ErrorHandler(Handler):
|
||||||
def filter(self, stanza, lang):
|
def filter(self, stanza, lang_class):
|
||||||
raise Exception("test error")
|
raise Exception("test error")
|
||||||
|
|
||||||
class TestUnsubscribeHandler(DefaultUnsubscribeHandler):
|
class TestUnsubscribeHandler(DefaultUnsubscribeHandler):
|
||||||
def filter(self, message, lang):
|
def filter(self, message, lang_class):
|
||||||
if re.compile(".*%.*").match(message.get_to().node):
|
if re.compile(".*%.*").match(message.get_to().node):
|
||||||
# return no account because self.handle does not need an account
|
# return no account because self.handle does not need an account
|
||||||
return []
|
return []
|
||||||
|
|||||||
Reference in New Issue
Block a user