def _make_key(self, name, action=None, target=None): segments = [ self.storage.add_prefix('uid'), manager.make_uid(self.instance), name, ] if target: if isinstance(target, six.string_types): segments += ['target', target] else: if isinstance(target, models.Model) or issubclass( target, models.Model): segments += ['target', registry.get_identifier(target)] if action: if isinstance(action, six.string_types): segments += ['verb', action] elif issubclass(action, Action): segments += ['verb', action.verb] key = get_key(*segments) return key
def _get_read_key(self): segments = [ self.storage.add_prefix('uid'), manager.make_uid(self.instance), 'read_at' ] return get_key(*segments)
def _get_keys(self, action): identifier = registry.get_identifier(self.instance) prefix = self.storage.add_prefix('uid') uid = manager.make_uid(self.instance) keys = [ get_key(prefix, uid, 'private'), get_key(prefix, uid, 'private', 'target', identifier) ] if action.actor == self.instance: keys.append(get_key(prefix, uid, 'public')) keys.append(get_key(prefix, uid, 'public', 'target', identifier)) if action.target is not None and action.target != action.actor: identifier = registry.get_identifier(action.target) keys.append(get_key(prefix, uid, 'private', 'target', identifier)) if action.actor == self.instance: keys.append(get_key(prefix, uid, 'public', 'target', identifier)) return keys
def _get_keys(self, action): identifier = registry.get_identifier(self.instance) prefix = self.storage.add_prefix('uid') uid = manager.make_uid(self.instance) keys = [ get_key(prefix, uid, 'private'), get_key(prefix, uid, 'private', 'target', identifier) ] if action.actor == self.instance: keys.append(get_key(prefix, uid, 'public')) keys.append(get_key(prefix, uid, 'public', 'target', identifier)) if action.target is not None and action.target != action.actor: identifier = registry.get_identifier(action.target) keys.append(get_key(prefix, uid, 'private', 'target', identifier)) if action.actor == self.instance: keys.append( get_key(prefix, uid, 'public', 'target', identifier)) return keys
def _make_key(self, name, action=None, target=None): segments = [ self.storage.add_prefix('uid'), manager.make_uid(self.instance), name, ] if target: if isinstance(target, six.string_types): segments += ['target', target] else: if isinstance(target, models.Model) or issubclass(target, models.Model): segments += ['target', registry.get_identifier(target)] if action: if isinstance(action, six.string_types): segments += ['verb', action] elif issubclass(action, Action): segments += ['verb', action.verb] key = get_key(*segments) return key
def handle_follow(sender, from_instance, to_instance, *args, **kwargs): import_actions.delay(to_uid=manager.make_uid(from_instance), from_uid=manager.make_uid(to_instance))
def target_uid(self): if self.target: return backend.make_uid(self.target) return None
def actor_uid(self): return backend.make_uid(self.actor)
def handle_unfollow(sender, from_instance, to_instance, *args, **kwargs): remove_actions.delay(to_uid=manager.make_uid(from_instance), from_uid=manager.make_uid(to_instance))