Commit 8369066d authored by Antoine Millet's avatar Antoine Millet
Browse files

Changed API for CCSAsyncTagInterface

Take a callback to the tag update method and no more the whole
client object.
parent d5191bbb
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -227,7 +227,7 @@ class Client(object):
        :param value: value of the tag
        """

        tag = RemoteTag(name, self, ttl=ttl)
        tag = RemoteTag(name, self.async_remote_tags, ttl=ttl)
        self._tql_object.register(tag)
        self._remote_tags.add(name)

+10 −6
Original line number Diff line number Diff line
@@ -74,16 +74,16 @@ class RemoteTag(BaseTag):
    """ A tag which is available remotely on a client.
    """

    def __init__(self, name, client, ttl=None):
    def __init__(self, name, callback, ttl=None):
        super(RemoteTag, self).__init__(name)
        self._client = client
        self._callback = callback
        self._ttl = ttl if ttl != -1 else None   #FIXME: ANAEL !!!!
        self._cache_last_update = None
        self._cache_value = u''

    @property
    def client(self):
        return self._client
    def callback(self):
        return self._callback

    @property
    def ttl(self):
@@ -144,8 +144,12 @@ class SRequestor(StaticRequestor):
                except tag.OutdatedCacheError:
                    to_update.add(tag)
            if to_update:
                client = tuple(to_update)[0].client  # Same client for all remote tags of an object
                client.async_remote_tags(watcher, obj, [t.name for t in to_update])
                # All remote tags of an object are always bound to the same
                # client. Request for tag value is made in a single call to
                # avoid multiple query/response, so we take the callback from
                # the first tag to do the update on the whole:
                cb = tuple(to_update)[0].callback
                cb(watcher, obj, [t.name for t in to_update])
        # Get and process the results:
        for update in watcher.wait(timeout=60):  #TODO: adaptative timeout
            obj = update['data']