From 9e58a69285d3fd3d22c23b96812444c5ab2b7736 Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Tue, 16 Sep 2014 13:51:51 +0200 Subject: [PATCH] [TASK] Rename Citavi.CitaviProject to Citavi.Project. Introduce Mapper class. --- frontend/views.py | 4 ++-- service/Citavi.py | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/frontend/views.py b/frontend/views.py index 627bab1..de6155b 100644 --- a/frontend/views.py +++ b/frontend/views.py @@ -137,7 +137,7 @@ class UpdateProjectView(ProtectedFormView, SingleObjectMixin): """ Test if SQLite is a valid citavi project. """ from service import Citavi - citavi_project = Citavi.CitaviProject(temp_sqlite) + citavi_project = Citavi.Project(temp_sqlite) citavi_project_valid = citavi_project.is_valid() """ Free temporary ressources. """ del citavi_project @@ -163,7 +163,7 @@ class UpdateProjectView(ProtectedFormView, SingleObjectMixin): """ Refresh identities from citavi project. """ # TODO - #citavi_project = Citavi.CitaviProject(sqlite_path) + #citavi_project = Citavi.Project(sqlite_path) #del citavi_project return super(UpdateProjectView, self).form_valid(form) diff --git a/service/Citavi.py b/service/Citavi.py index 747b420..bdad476 100644 --- a/service/Citavi.py +++ b/service/Citavi.py @@ -5,7 +5,7 @@ from sqlalchemy.ext.automap import automap_base from sqlalchemy.orm import Session -class CitaviProject(): +class Project(): """ A helper class representing a Citavi project. """ def __init__(self, sqlite_file): """ Constructor to get absolute path to sqlite. """ @@ -24,9 +24,15 @@ class CitaviProject(): return self._is_open and not self._is_error def get_persons(self): + """ Returns all persons from the Citavi project. """ try: - PersonClass = self._sa_sqlite_autobase.classes.Person + person_class = self._sa_sqlite_autobase.classes.Person + citavi_persons = self._sa_sqlite_session.query(person_class).all() + return citavi_persons except: + self._is_error = True + # TODO: better error handling! + print "An error occured within a get_person call!" return False def open(self): @@ -71,6 +77,15 @@ class CitaviProject(): pass +class Mapper(): + """ A class encapsulating the django models for mapping against Citavi projects. """ + def __init__(self): + pass + + def __del__(self): + pass + +