def _make_command_method(cls, command_name, many=False):
        """
        Return a function which will convert objects to their pk, then call the
        super method for the given name.
        The "many" attribute indicates that the command accept one or many
        values as arguments (in *args)
        """
        def func(self, *args, **kwargs):
            if many:
                args = self.from_python_many(*args)
            else:
                if 'value' in kwargs:
                    kwargs['value'] = self.from_python(kwargs['value'])
                else:
                    args = list(args)
                    args[0] = self.from_python(args[0])

            # call the super method, with real pk
            sup_method = getattr(super(cls, self), command_name)
            return sup_method(*args, **kwargs)
        return func