def create_person(self, data, person_type=None): self._check_person_data(data) try: with self._database_engine.new_session() as session: member = PersonDAO(session).get_dao(type=person_type).create(data) member_data = member.to_dict() return member_data except Error as e: raise e
def create_person(self, data): self._check_profile_data(data) try: with self._database_engine.new_session() as session: # Save person in database person = PersonDAO(session).create(data) person_data = person.to_dict() return person_data except Error as e: # log error raise e
def get_person_by_username(self, username): with self._database_engine.new_session() as session: user = UserDAO(session).get_by_name(username) person = PersonDAO(session).get_by_id_user(user.id) person_data = person.to_dict() return person_data
def get_person_by_name(self, firstname, lastname): with self._database_engine.new_session() as session: person = PersonDAO(session).get_by_name(firstname, lastname) person_data = person.to_dict() return person_data
def get_person(self, person_id): with self._database_engine.new_session() as session: person = PersonDAO(session).get(person_id) person_data = person.to_dict() return person_data
def _update_person(self, member_id, member_data, person_type=None): with self._database_engine.new_session() as session: person = PersonDAO(session).get_dao(type=person_type).get(member_id) person = PersonDAO(session).get_dao(type=person_type).update(person, member_data) return person.to_dict()
def get_person(self, person_id, person_type=None): with self._database_engine.new_session() as session: member = PersonDAO(session).get_dao(type=person_type).get(person_id) member_data = member.to_dict() return member_data