示例#1
0
    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
示例#2
0
    def _get_read_key(self):
        segments = [
            self.storage.add_prefix('uid'),
            manager.make_uid(self.instance), 'read_at'
        ]

        return get_key(*segments)
示例#3
0
    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
示例#4
0
    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
示例#5
0
    def _get_read_key(self):
        segments = [
            self.storage.add_prefix('uid'),
            manager.make_uid(self.instance),
            'read_at'
        ]

        return get_key(*segments)
示例#6
0
    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
示例#7
0
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))
示例#8
0
    def target_uid(self):
        if self.target:
            return backend.make_uid(self.target)

        return None
示例#9
0
 def actor_uid(self):
     return backend.make_uid(self.actor)
示例#10
0
    def target_uid(self):
        if self.target:
            return backend.make_uid(self.target)

        return None
示例#11
0
 def actor_uid(self):
     return backend.make_uid(self.actor)
示例#12
0
 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))