code: def get_model(sender, model_name, model_inst, model_info, model_config):
      
      MC = get_mc()
      if MC:
          model = MC.get((MC.c.model_name==model_name) & (MC.c.uuid!=''))
          if model:
              cached_inst = __cache__.get(model_name)
              if not cached_inst or (cached_inst and cached_inst[1]!=model.uuid):
                  model_inst = model.get_instance()
                  M = orm.create_model(model_name, fields=eval(model_inst.fields or '[]'),
                                       indexes=eval(model_inst.indexes or '[]'),
                                       basemodel=model_inst.basemodel,
                                       __replace__=True)
                  __cache__[model_name] = (M, model.uuid)
  
                  #process extension model
                  if model_inst.has_extension:
                      ext_model_name = model_name + '_extension'
                      fields = eval(model_inst.extension_fields or '[]')
                      fields.insert(0, {'name':'_parent', 'type':'OneToOne', 'reference_class':model_name, 'collection_name':'ext'})
                      ME = orm.create_model(ext_model_name, fields=fields,
                                            indexes=eval(model_inst.extension_indexes or '[]'),
                                            basemodel=model_inst.extension_model,
                                            __replace__=True)
  
              else:
                  M = cached_inst[0]
  
              return M
docs: #todo Add objcache support