Merge remote-tracking branch 'vijayp/master' into HEAD

Conflicts:
	examples/ping.py
	sleekxmpp/basexmpp.py
	sleekxmpp/clientxmpp.py
	sleekxmpp/features/feature_bind/bind.py
	sleekxmpp/features/feature_mechanisms/mechanisms.py
	sleekxmpp/plugins/gmail_notify.py
	sleekxmpp/plugins/jobs.py
	sleekxmpp/plugins/xep_0009/remote.py
	sleekxmpp/plugins/xep_0009/rpc.py
	sleekxmpp/plugins/xep_0012.py
	sleekxmpp/plugins/xep_0045.py
	sleekxmpp/plugins/xep_0050/adhoc.py
	sleekxmpp/plugins/xep_0078/legacyauth.py
	sleekxmpp/plugins/xep_0085/chat_states.py
	sleekxmpp/plugins/xep_0199/ping.py
	sleekxmpp/plugins/xep_0224/attention.py
	sleekxmpp/xmlstream/handler/waiter.py
	sleekxmpp/xmlstream/matcher/xmlmask.py
	sleekxmpp/xmlstream/xmlstream.py

Conflicts:
	examples/ping.py
	sleekxmpp/basexmpp.py
	sleekxmpp/clientxmpp.py
	sleekxmpp/features/feature_bind/bind.py
	sleekxmpp/features/feature_mechanisms/mechanisms.py
	sleekxmpp/plugins/gmail_notify.py
	sleekxmpp/plugins/jobs.py
	sleekxmpp/plugins/xep_0009/remote.py
	sleekxmpp/plugins/xep_0009/rpc.py
	sleekxmpp/plugins/xep_0012.py
	sleekxmpp/plugins/xep_0045.py
	sleekxmpp/plugins/xep_0050/adhoc.py
	sleekxmpp/plugins/xep_0078/legacyauth.py
	sleekxmpp/plugins/xep_0085/chat_states.py
	sleekxmpp/plugins/xep_0199/ping.py
	sleekxmpp/plugins/xep_0224/attention.py
	sleekxmpp/xmlstream/handler/waiter.py
	sleekxmpp/xmlstream/matcher/xmlmask.py
	sleekxmpp/xmlstream/xmlstream.py
This commit is contained in:
Lance Stout 2011-11-19 18:23:26 -08:00
commit b54cc97e4c
2 changed files with 26 additions and 21 deletions

View file

@ -246,7 +246,7 @@ class BaseXMPP(XMLStream):
spec = "(RFC-%s) " % self.plugin[plugin].rfc spec = "(RFC-%s) " % self.plugin[plugin].rfc
desc = (spec, self.plugin[plugin].description) desc = (spec, self.plugin[plugin].description)
log.debug("Loaded Plugin %s%s", desc) log.debug("Loaded Plugin %s", desc)
except: except:
log.exception("Unable to load plugin: %s", plugin) log.exception("Unable to load plugin: %s", plugin)

View file

@ -873,20 +873,25 @@ class XMLStream(object):
event queue. All event handlers will run in the event queue. All event handlers will run in the
same thread. same thread.
""" """
for handler in self.__event_handlers.get(name, []): handlers = self.__event_handlers.get(name, [])
for handler in handlers:
#TODO: Data should not be copied, but should be read only,
# but this might break current code so it's left for future.
out_data = copy.copy(data) if len(handlers) > 1 else data
old_exception = getattr(data, 'exception', None)
if direct: if direct:
try: try:
handler[0](copy.copy(data)) handler[0](out_data)
except Exception as e: except Exception as e:
error_msg = 'Error processing event handler: %s' error_msg = 'Error processing event handler: %s'
log.exception(error_msg, str(handler[0])) log.exception(error_msg, str(handler[0]))
if hasattr(data, 'exception'): if old_exception:
data.exception(e) old_exception(e)
else: else:
self.exception(e) self.exception(e)
else: else:
self.event_queue.put(('event', handler, copy.copy(data))) self.event_queue.put(('event', handler, out_data))
if handler[2]: if handler[2]:
# If the handler is disposable, we will go ahead and # If the handler is disposable, we will go ahead and
# remove it now instead of waiting for it to be # remove it now instead of waiting for it to be
@ -1200,9 +1205,9 @@ class XMLStream(object):
# to run "in stream" will be executed immediately; the rest will # to run "in stream" will be executed immediately; the rest will
# be queued. # be queued.
unhandled = True unhandled = True
for handler in self.__handlers: matched_handlers = filter(lambda h: h.match(stanza), self.__handlers)
if handler.match(stanza): for handler in matched_handlers:
stanza_copy = copy.copy(stanza) stanza_copy = copy.copy(stanza) if len(matched_handlers) > 1 else stanza
handler.prerun(stanza_copy) handler.prerun(stanza_copy)
self.event_queue.put(('stanza', handler, stanza_copy)) self.event_queue.put(('stanza', handler, stanza_copy))
try: try:
@ -1226,7 +1231,8 @@ class XMLStream(object):
func -- The event handler to execute. func -- The event handler to execute.
args -- Arguments to the event handler. args -- Arguments to the event handler.
""" """
orig = copy.copy(args[0]) # this is always already copied before this is invoked
orig = args[0]
try: try:
func(*args) func(*args)
except Exception as e: except Exception as e:
@ -1278,7 +1284,6 @@ class XMLStream(object):
self.exception(e) self.exception(e)
elif etype == 'event': elif etype == 'event':
func, threaded, disposable = handler func, threaded, disposable = handler
orig = copy.copy(args[0])
try: try:
if threaded: if threaded:
x = threading.Thread( x = threading.Thread(