hooks/syncsources.py
changeset 7024 f4e798cf29b4
parent 6957 ffda12be2e9f
child 7049 f2ae6202754c
--- a/hooks/syncsources.py	Fri Feb 18 17:11:00 2011 +0100
+++ b/hooks/syncsources.py	Fri Feb 18 17:07:40 2011 +0100
@@ -17,6 +17,8 @@
 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
 """hooks for repository sources synchronization"""
 
+from socket import gethostname
+
 from yams.schema import role_name
 
 from cubicweb import ValidationError
@@ -87,11 +89,15 @@
     __select__ = SourceHook.__select__ & is_instance('CWSourceHostConfig')
     events = ('after_add_entity', 'after_update_entity', 'before_delete_entity',)
     def __call__(self):
-        try:
-            SourceUpdatedOp.get_instance(self._cw).add_data(self.entity.cwsource)
-        except IndexError:
-            # XXX no source linked to the host config yet
-            pass
+        if self.entity.match_host(gethostname()):
+            if self.event == 'after_update_entity' and \
+                   not 'config' in self.entity.cw_edited:
+                return
+            try:
+                SourceUpdatedOp.get_instance(self._cw).add_data(self.entity.cwsource)
+            except IndexError:
+                # XXX no source linked to the host config yet
+                pass
 
 
 # source mapping synchronization. Expect cw_for_source/cw_schema are immutable