def get_user_for_principal_id(principal_id): """Get the User for this principal_id. """ # !+group_principal(mr, may-2012) and when principal_id is for a group? query = Session().query(domain.User).filter(domain.User.login == principal_id) try: return query.one() except rdb.exc.InvalidRequestError: # !+ sqlalchemy.orm.exc NoResultFound, MultipleResultsFound return None
def get_user_for_principal_id(principal_id): """Get the User for this principal_id. """ # !+group_principal(mr, may-2012) and when principal_id is for a group? query = Session().query( domain.User).filter(domain.User.login == principal_id) try: return query.one() except rdb.exc.InvalidRequestError: # !+ sqlalchemy.orm.exc NoResultFound, MultipleResultsFound return None
def get(self, name, default=None): try: domain_class, principal_name = self.value_key(name) except ValueError: return default query = Session().query(domain_class ).filter(domain_class.principal_name == principal_name) try: value = query.one() except orm.exc.NoResultFound: return default return contained(value, self, name)
def get(self, name, default=None): try: domain_class, principal_name = self.value_key(name) except ValueError: return default query = Session().query(domain_class).filter( domain_class.principal_name == principal_name) try: value = query.one() except orm.exc.NoResultFound: return default return contained(value, self, name)