Retrieve a :class:`Model` from its universally unique identifier
``uuid``. If the ``uuid`` does not match any instance an exception will raise.
497640
def from_uuid(self, uuid, session=None):
        '''
'''
        elems = uuid.split('.')
        if len(elems) == 2:
            model = get_model_from_hash(elems[0])
            if not model:
                raise Model.DoesNotExist(
                    'model id "{0}" not available'.format(elems[0]))
            if not session or session.router is not self:
                session = self.session()
            return session.query(model).get(id=elems[1])
        raise Model.DoesNotExist('uuid "{0}" not recognized'.format(uuid))
1113490
def get(self, key):
        
        try:
            return self[self.id_lookup.get(key)]

        except TypeError:
            raise KeyError
1007752
def extract_instance_id(state_error):
    ""
    instance_id = None
    match = RE_ERROR_INSTANCE_ID.search(str(state_error))
    if match:
        instance_id = match.groupdict().get('instance_id')
    if match is None or instance_id is None:
        raise ValueError("Could not extract instance id from error: %s" % state_error)
    return instance_id
677356
def uuid(self, version: int = None) -> str:
        
        bits = self.random.getrandbits(128)
        return str(uuid.UUID(int=bits, version=version))
1335882
def get(self, model, **spec):
        

        handles = self.__find_handles(model, **spec)
        if len(handles) > 1:
            raise MultipleObjectsReturned()
        if not handles:
            raise ObjectDoesNotExist()
        return self.get_instance(model, handles[0])
622900
def get_uuid(obj):
    """"""
    # TODO: deprecate null uuid ret val
    from uuid import UUID
    try:
        uuid = obj.attrs['uuid']
    except KeyError:
        return UUID(int=0)
    # convert to unicode for python 3
    try:
        uuid = uuid.decode('ascii')
    except (LookupError, AttributeError):
        pass
    return UUID(uuid)
1306633
def get_or_exception(cls, id):
        '''  '''
        obj = cls.get(id)

        if obj is None:
            raise ModelNotFoundError('This object does not exist in database')

        return obj
634514
def validate_uuid(value):
    

    if value and not isinstance(value, UUID):
        try:
            return UUID(str(value), version=4)
        except (AttributeError, ValueError):
            raise ValidationError('not a valid UUID')
    return value
1364004
def get(self, id):
        
        with rconnect() as conn:
            if id is None:
                raise ValueError

            if isinstance(id, uuid.UUID):
                id = str(id)

            if type(id) != str and type(id) != unicode:
                raise ValueError

            try:
                query = self._base().get(id)
                log.debug(query)
                rv = query.run(conn)
            except ReqlOpFailedError as e:
                log.warn(e)
                raise
            except Exception as e:
                log.warn(e)
                raise
            if rv is not None:
                return self._model(rv)

            return None
1096419
public T get(final UUID _uuid)
    {
        return getCache4UUID() == null ? null : getCache4UUID().get(_uuid);
    }
93583
def uuid(cls):
        """"""
        if hasattr(cls, '__uuid_primary_key__') and cls.__uuid_primary_key__:
            return synonym('id')
        else:
            return immutable(Column(UUIDType(binary=False), default=uuid_.uuid4, unique=True, nullable=False))
945260
def get_object(table, id=None, condition=None, cache=False, fields=None, use_local=False,
               engine_name=None, session=None):
    
    from uliweb import functions, settings
    
    model = get_model(table, engine_name)
        
    #if id is an object of Model, so get the real id value
    if isinstance(id, Model):
        return id
      
    if cache:
        if use_local:
            s = get_session(session)
            key = get_object_id(s.engine_name, model.tablename, id)
            value = s.get_local_cache(key)
            if value:
                return value
        obj = model.get(id, condition=condition, fields=fields, cache=True)
        if use_local:
            value = s.get_local_cache(key, obj)
    else:
        obj = model.get(id, condition=condition, fields=fields)
    
    return obj
217703
def uuid(uuid_value=None):
        
        if uuid_value:
            if not validate_uuid(uuid_value):
                raise ValueError(
                    "uuid_value must be a valid UUID version 4 object")
        else:
            uuid_value = uuid.uuid4()

        if versions_settings.VERSIONS_USE_UUIDFIELD:
            return uuid_value
        else:
            return six.u(str(uuid_value))
657767
def get_from_ident(self, ident):
        
        model_repr, job_pk = ident.split(':', 1)
        klass = import_class(model_repr)
        return klass.get(job_pk)
1137516
def get_or_create_model_key(self):
        
        model_cache_info = model_cache_backend.retrieve_model_cache_info(self.model._meta.db_table)
        if not model_cache_info:
            return uuid.uuid4().hex, True
        return model_cache_info.table_key, False
668200
def get_existing_model(model_name):
    
    try:
        model_cls = engine.get_document_cls(model_name)
        log.debug('Model `{}` already exists. Using existing one'.format(
            model_name))
        return model_cls
    except ValueError:
        log.debug('Model `{}` does not exist'.format(model_name))
1064019
def _get_model_instance(model_cls, data):
        
        if not isinstance(data, (model_cls, dict)):
            raise TypeError('{0} is not valid type, instance of '
                            '{1} or dict required'.format(data, model_cls))
        return model_cls(**data) if isinstance(data, dict) else data