def get_by_key_name(cls, key_names, parent=None, **kwargs): try: if not parent: parent = cls.db_parent parent = db._coerce_to_key(parent) except db.BadKeyError, e: raise db.BadArgumentError(str(e))
def get_by_key_name(cls, key_names, parent=None, **kwargs): """Get instance of Model class by its key's name. Keeps the same comportement of db.Model.get_by_key_name() TODO(sahid): Needs doc. """ try: parent = db._coerce_to_key(parent) except db.BadKeyError, e: raise db.BadArgumentError(str(e))
def get_by_id(cls, ids, parent=None, **kwds): """Get instance of Model class by id from the given storage layers. Args: See pdb.get Inherited: ids: A single id or a list of ids. parent: Parent of instances to get. Can be a model or key. """ try: parent = db._coerce_to_key(parent) except db.BadKeyError, e: raise db.BadArgumentError(str(e))
def _to_mutexes(mutexes_or_keys): """Normalizes and type checks the given sequence. Args: mutexes_or_keys: sequence of Mutex objects or keys Returns: list of Mutexes """ mutexes = [] for arg in mutexes_or_keys: if isinstance(arg, Mutex): mutexes.append(arg) elif isinstance(arg, db.Key): mutexes.append(Mutex.get(arg)) else: raise db.BadArgumentError( 'Expected a Mutex instance or key; received %s (a %s).' % (arg, datastore.typename(arg))) return mutexes