def _apply_to_values(self, entity, function):
value = self._retrieve_value(entity, self._default)<EOL>if self._repeated:<EOL><INDENT>if value is None:<EOL><INDENT>value = []<EOL>self._store_value(entity, value)<EOL><DEDENT>else:<EOL><INDENT>value[:] = map(function, value)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if value is not None:<EOL><INDENT>newvalue = function(value)<EOL>if newvalue is not None and newvalue is not value:<EOL><INDENT>self._store_value(entity, newvalue)<EOL>value = newvalue<EOL><DEDENT><DEDENT><DEDENT>return value<EOL>
Apply a function to the property value/values of a given entity.

        This retrieves the property value, applies the function, and then
        stores the value back.  For a repeated property, the function is
        applied separately to each of the values in the list.  The
        resulting value or list of values is both stored back in the
        entity and returned from this method.