diff src/memory/memory.py @ 1315:be3a301540c0 frontends_multi_profiles

core (memory): updateEntityData now accept a "silent" argument to avoid sending signal to frontends when updating an attribute with "signalOnUpdate" flag.
author Goffi <goffi@goffi.org>
date Mon, 09 Feb 2015 21:39:51 +0100
parents bb9c32249778
children 3a20312d4012
line wrap: on
line diff
--- a/src/memory/memory.py	Mon Feb 09 21:39:51 2015 +0100
+++ b/src/memory/memory.py	Mon Feb 09 21:39:51 2015 +0100
@@ -444,7 +444,7 @@
         @param profile_key: %(doc_profile_key)s
         """
         presence_data = PresenceTuple(show, priority, statuses)
-        self.updateEntityData(entity_jid, "presence", presence_data, profile_key)
+        self.updateEntityData(entity_jid, "presence", presence_data, profile_key=profile_key)
         if entity_jid.resource and show != C.PRESENCE_UNAVAILABLE:
             # If a resource is available, bare jid should not have presence information
             try:
@@ -580,7 +580,7 @@
                 full_jid.resource = resource
                 yield full_jid
 
-    def updateEntityData(self, entity_jid, key, value, profile_key):
+    def updateEntityData(self, entity_jid, key, value, silent=False, profile_key=C.PROF_KEY_NONE):
         """Set a misc data for an entity
 
         If key was registered with setSignalOnUpdate, a signal will be sent to frontends
@@ -588,6 +588,7 @@
                            C.ENTITY_ALL for all entities (all resources + bare jids)
         @param key: key to set (eg: "type")
         @param value: value for this key (eg: "chatroom")
+        @param silent(bool): if True, doesn't send signal to frontend, even there is a signal flag (see setSignalOnUpdate)
         @param profile_key: %(doc_profile_key)s
         """
         profile_cache = self._getProfileCache(profile_key)
@@ -600,7 +601,7 @@
             entity_data = profile_cache.setdefault(jid_.userhostJID(),{}).setdefault(jid_.resource, {})
 
             entity_data[key] = value
-            if key in self._key_signals:
+            if key in self._key_signals and not silent:
                 if not isinstance(value, basestring):
                     log.error(u"Setting a non string value ({}) for a key ({}) which has a signal flag".format(value, key))
                 else: