def save_model(self, model, meta_data=None, index_fields=None):
<EOL>if settings.DEBUG:<EOL><INDENT>t1 = time.time()<EOL><DEDENT>clean_value = model.clean_value()<EOL>model._data = clean_value<EOL>if settings.DEBUG:<EOL><INDENT>t2 = time.time()<EOL><DEDENT>if not model.exist:<EOL><INDENT>obj = self.bucket.new(data=clean_value).store()<EOL>model.key = obj.key<EOL>new_obj = True<EOL><DEDENT>else:<EOL><INDENT>new_obj = False<EOL>obj = self.bucket.get(model.key)<EOL>obj.data = clean_value<EOL>obj.store()<EOL><DEDENT>if settings.ENABLE_VERSIONS:<EOL><INDENT>version_key = self._write_version(clean_value, model)<EOL><DEDENT>else:<EOL><INDENT>version_key = '<STR_LIT>'<EOL><DEDENT>if settings.ENABLE_CACHING:<EOL><INDENT>self.set_to_cache((clean_value, model.key))<EOL><DEDENT>meta_data = meta_data or model.save_meta_data<EOL>if settings.ENABLE_ACTIVITY_LOGGING and meta_data:<EOL><INDENT>self._write_log(version_key, meta_data, index_fields)<EOL><DEDENT>if self.COLLECT_SAVES and self.COLLECT_SAVES_FOR_MODEL == model.__class__.__name__:<EOL><INDENT>self.block_saved_keys.append(obj.key)<EOL><DEDENT>if settings.DEBUG:<EOL><INDENT>if new_obj:<EOL><INDENT>sys.PYOKO_STAT_COUNTER['<STR_LIT>'] += <NUM_LIT:1><EOL>sys.PYOKO_LOGS['<STR_LIT>'].append(obj.key)<EOL><DEDENT>else:<EOL><INDENT>sys.PYOKO_LOGS[self._model_class.__name__].append(obj.key)<EOL>sys.PYOKO_STAT_COUNTER['<STR_LIT>'] += <NUM_LIT:1><EOL><DEDENT><DEDENT>return model<EOL>
model (instance): Model instance.
    meta (dict): JSON serializable meta data for logging of save operation.
        {'lorem': 'ipsum', 'dolar': 5}
    index_fields (list): Tuple list for indexing keys in riak (with 'bin' or 'int').
        [('lorem','bin'),('dolar','int')]
:return: