adminapi.request.json_encode_extra - python examples

Here are the examples of the python api adminapi.request.json_encode_extra taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

3 Examples 7

3 View Complete Implementation : __init__.py
Copyright MIT License
Author : innogames
    def commit_state(self):
        if self.object_id is None:
            return 'created'
        if self._deleted:
            return 'deleted'
        for attribute_id, old_value in self.old_values.items():
            if (
                json_encode_extra(self[attribute_id]) !=
                json_encode_extra(old_value)
            ):
                return 'changed'
        return 'consistent'

0 View Complete Implementation : __init__.py
Copyright MIT License
Author : innogames
    def _serialize_changes(self):
        changes = {'object_id': self.object_id}
        for key, old_value in self.old_values.items():
            new_value = self[key]

            if (
                json_encode_extra(old_value) ==
                json_encode_extra(new_value)
            ):
                continue

            if isinstance(old_value, MultiAttr):
                action = 'multi'
            else:
                action = 'update'

            change = {'action': action}
            if action == 'update':
                change['old'] = old_value
                change['new'] = new_value
            elif action == 'multi':
                change['remove'] = old_value.difference(new_value)
                change['add'] = new_value.difference(old_value)

            changes[key] = change

        return changes

0 View Complete Implementation : query_committer.py
Copyright MIT License
Author : innogames
def _validate_commit(changes, servers):
    newer = []
    for attribute_changes in changes:
        object_id = attribute_changes['object_id']
        server = servers[object_id]
        for attr, change in attribute_changes.items():
            if attr == 'object_id':
                continue

            action = change['action']
            if action == 'new':
                if attr in server:
                    newer.append((object_id, attr, server[attr]))
            elif action == 'update' or action == 'delete':
                try:
                    if json_encode_extra(server[attr]) != str(change['old']):
                        newer.append((object_id, attr, server[attr]))
                except KeyError:
                    newer.append((object_id, attr, None))

    return newer