def set(self, *args, **kwargs):
        ''' Usage is either:

            set(self, qfield, value): Atomically set ``qfield`` to ``value``

            OR

            set(key1=value1, key2=value2): Atomically set the named arguments
            on the current object to the values given.  This form cannot
            update a sub-document
            '''
        if len(args) == 2:
            qfield, value = args
            return self._atomic_op('$set', qfield, value)
        elif len(kwargs) != 0:
            ret = self
            for key, value in kwargs.items():
                ret = ret._atomic_op('$set', key, value)
            return ret
        else:
            raise UpdateException('Invalid arguments for set.  Requires either two positional arguments or at least one keyword argument')
Usage is either:

            set(self, qfield, value): Atomically set ``qfield`` to ``value``

            OR

            set(key1=value1, key2=value2): Atomically set the named arguments
            on the current object to the values given.  This form cannot
            update a sub-document