[Mpuls-commits] r863 - wasko/branches/2.0/waskaweb/model

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Jan 26 11:19:17 CET 2010


Author: torsten
Date: 2010-01-26 11:19:17 +0100 (Tue, 26 Jan 2010)
New Revision: 863

Removed:
   wasko/branches/2.0/waskaweb/model/repeatgroup.py
Log:
* waskaweb/model/repeatgroup.py: Deleted. Not imported anywhere


Deleted: wasko/branches/2.0/waskaweb/model/repeatgroup.py
===================================================================
--- wasko/branches/2.0/waskaweb/model/repeatgroup.py	2010-01-26 10:17:42 UTC (rev 862)
+++ wasko/branches/2.0/waskaweb/model/repeatgroup.py	2010-01-26 10:19:17 UTC (rev 863)
@@ -1,248 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (c) 2007 by Intevation GmbH
-# Authors:
-#
-# Torsten Irlaender <torsten.irlaender at intevation.de>
-# Sascha L. Teichmann <teichmann at intevation.de>
-
-import sys
-import traceback 
-import time
-import datetime
-import traceback
-import psycopg2.extras
-
-from waskaweb.lib.db import db
-
-from waskaweb.lib.helpers import dd_mm_YYYY
-
-FETCH_AID_LIST_SQL     = """SELECT id FROM %s WHERE master_id = %s"""
-CREATE_RG_BILDEN_DS    = """SELECT create_rg_bilden_ds(%(id)s, %(uuid)s)"""
-CREATE_RG_LEBEN_DS     = """SELECT create_rg_leben_ds(%(id)s, %(uuid)s)"""
-CREATE_RG_QUALI_DS     = """SELECT create_rg_quali_ds(%(id)s, %(uuid)s)"""
-CREATE_RG_BERUF_DS     = """SELECT create_rg_beruf_ds(%(id)s, %(uuid)s)"""
-DELETE_RG_BILDEN_DS    = """select delete_rg_bilden_ds(%(id)s)"""
-DELETE_RG_LEBEN_DS     = """select delete_rg_leben_ds(%(id)s)"""
-DELETE_RG_QUALI_DS     = """select delete_rg_quali_ds(%(id)s)"""
-DELETE_RG_BERUF_DS     = """select delete_rg_beruf_ds(%(id)s)"""
-
-LOAD_RG_BILDEN_DS = """SELECT id, angebotsform as form, art_der_unterstuetzung as type, durchfuehrende_institution as institute, unterstuetzung_start as start, unterstuetzung_ende as end, zielsetzungangebot FROM rg_angebote_bildenden_bereich_tbl_view WHERE id = %s"""
-
-LOAD_RG_BERUF_DS = """SELECT r.id, r.angebotsform_1 as form, t.value as type, r.durchfuehrende_institution_1 as institute, r.unterstuetzung_start_1 as start, r.unterstuetzung_ende_1 as end, zielsetzungangebot FROM rg_angebote_berufsvorbereitung_tbl_view r JOIN art_der_unterstuetzung_1_tbl t ON r.art_der_unterstuetzung_1 = t.id WHERE r.id = %s"""
-
-LOAD_RG_QUALI_DS = """SELECT r.id, angebotsform_2 as form, t.value as type, durchfuehrende_institution_2 as institute, unterstuetzung_start_2 as start, unterstuetzung_ende_2 as end, zielsetzungangebot FROM rg_angebote_berufliche_qualifizierung_tbl_view r JOIN angebote_im_bereich_tbl t on r.angebote_im_bereich = t.id  WHERE r.id = %s"""
-
-LOAD_RG_LEBEN_DS = """SELECT r.id, angebotsform_3 as form, t.value as type, durchfuehrende_institution_3 as institute, unterstuetzung_start_3 as start, unterstuetzung_ende_3 as end, zielsetzungangebot FROM rg_angebote_lebensbewaeltigung_tbl_view r JOIN art_der_unterstuetzung_2_tbl t ON r.art_der_unterstuetzung_2 = t.id  WHERE r.id = %s"""
-
-RG_BILDEN_DB_TBL = "rg_angebote_bildenden_bereich_tbl_view"
-RG_BERUF_DB_TBL  = "rg_angebote_berufsvorbereitung_tbl_view"
-RG_QUALI_DB_TBL  = "rg_angebote_berufliche_qualifizierung_tbl_view"
-RG_LEBEN_DB_TBL  = "rg_angebote_lebensbewaeltigung_tbl_view"
-
-class NotFoundError(StandardError):
-    pass
-
-class AidList:
-    def __init__(self, case_id):
-        self.aid_list = []
-        for rg_type in range(0,4):
-            list = self._loadCases(rg_type, case_id)
-            self.aid_list.extend(self._buildAidObjects(rg_type, list))
-
-    def _buildAidObjects(self, type_id, list):
-        aid_list = []
-        factory = AidObjectFactory()
-        for id in list:
-            aid_list.append(factory.load(type_id, id))
-        return aid_list
-
-    def _loadCases(self, type_id, case_id):
-        conn, c = None, None
-        if type_id == 0: table = RG_BILDEN_DB_TBL 
-        if type_id == 1: table = RG_BERUF_DB_TBL 
-        if type_id == 2: table = RG_QUALI_DB_TBL 
-        if type_id == 3: table = RG_LEBEN_DB_TBL 
-        try:
-            try:
-                conn = db.getConnection()
-                c = conn.cursor()
-                sql = FETCH_AID_LIST_SQL % (table, case_id)
-                c.execute(sql)
-                result = c.fetchall()
-                return [id[0] for id in result]
-            finally:
-                db.recycleConnection(conn, c)
-        except:
-            traceback.print_exc(file=sys.stderr)
-            print >> sys.stderr, "%s" % c.query 
-            return []
-
-    def numDatasets(self):
-        return len(self.aid_list) 
-
-    def getDatasets(self):
-        return self.aid_list
-
-    def listDatasetIds(self, limit, ofs):
-        return [ds.id for ds in self.ds_list]
-
-class AidObjectFactory:
-    
-    def load(self, type_id, aid_id):
-        try:
-            if type_id == 0: return AidObject_BB(aid_id) 
-            if type_id == 1: return AidObject_BV(aid_id) 
-            if type_id == 2: return AidObject_BQ(aid_id) 
-            if type_id == 3: return AidObject_LB(aid_id)
-        except NotFoundError:
-            pass
-
-        return None
-
-    def create(self, type_id):
-        if type_id == 0: return AidObject_BB() 
-        if type_id == 1: return AidObject_BV() 
-        if type_id == 2: return AidObject_BQ() 
-        if type_id == 3: return AidObject_LB()
-        return None
-
-class AidObject:
-    def __init__(self, id):
-        self.id          = id
-        self.start_date  = "-/-"
-        self.end_date    = "-/-"
-        self.instutution = "-/-"
-        self.category    = "-/-"
-        self.aid_form    = "-/-"
-        self.type        = "-/-"
-        self.goal        = "-/-"
-        self.test        = "-/-"
-
-        self.category_id     = None 
-        self.page_id     = None 
-
-    def load(self, id):
-        r = self._load(id)
-        if r is None: raise NotFoundError()
-        try:
-            self.id          = r[0] 
-            self.aid_form    = unicode(str(r[1]), 'utf-8') # Angebotsform
-            self.type        = unicode(str(r[2]), 'utf-8') # Art der Unterstützung
-            self.institution = unicode(str(r[3]), 'utf-8')
-            self.start_date  = dd_mm_YYYY(r[4])
-            self.end_date    = dd_mm_YYYY(r[5])
-            self.goal        = unicode(str(r[6]), 'utf-8') # Zielsetzung
-        except AttributeError:
-            # Not all fields does have a value here. Nothing worse... so ignore it.
-            pass
-
-    def create(self, id, uuid=None):
-        return self._create(id, uuid)
-
-    def delete(self):
-        return self._delete()
-
-    def _load(self, id):
-        conn, cur = None, None
-        try:
-            try:
-                conn = db.getConnection()
-                cur  = conn.cursor()
-                sql  = self.load_sql % id
-                cur.execute(sql)
-                r    = cur.fetchone()
-                return r 
-            finally:
-                db.recycleConnection(conn, cur)
-        except:
-            traceback.print_exc(file=sys.stderr)
-
-    def _delete(self):
-        conn, cur, sql = None, None, None
-        try:
-            try:
-                conn = db.getConnection()
-                cur = conn.cursor()
-                cur.execute(self.delete_sql, { 'id': self.id })
-                conn.commit()
-            finally:
-                db.recycleConnection(conn, cur)
-        except StandardError, err:
-            print >> sys.stderr, "Error on deleting aid object", str(err), " ", sql 
-        return True
-
-    def _create(self, case_id, uuid=None):
-        try:
-            conn, cur = None, None
-            try:
-                conn = db.getConnection()
-                cur = conn.cursor()
-                cur.execute(self.create_sql, { 'id': case_id, 'uuid': uuid })
-                r = cur.fetchone()
-                conn.commit()
-                self.id = r[0]
-            finally:
-                db.recycleConnection(conn, cur)
-        except:
-            traceback.print_exc(file=sys.stderr)
-
-        return self.id
-
-class AidObject_BB(AidObject):
-
-    def __init__(self, id=None):
-        AidObject.__init__(self, id)
-        self.category    = "BB"
-        self.category_id = 0 
-        self.page_id = 27
-
-        self.load_sql     = LOAD_RG_BILDEN_DS 
-        self.create_sql   = CREATE_RG_BILDEN_DS
-        self.delete_sql   = DELETE_RG_BILDEN_DS
-        if id:
-            self.load(id)
-
-class AidObject_BV(AidObject):
-
-    def __init__(self, id=None):
-        AidObject.__init__(self, id)
-        self.category    = "BV"
-        self.category_id = 1 
-        self.page_id = 28
-
-        self.load_sql     = LOAD_RG_BERUF_DS
-        self.create_sql   = CREATE_RG_BERUF_DS
-        self.delete_sql   = DELETE_RG_BERUF_DS
-        if id:
-            self.load(id)
-
-class AidObject_BQ(AidObject):
-
-    def __init__(self, id=None):
-        AidObject.__init__(self, id)
-        self.category    = "BQ"
-        self.category_id = 2 
-        self.page_id = 29
-
-        self.load_sql     = LOAD_RG_QUALI_DS 
-        self.create_sql   = CREATE_RG_QUALI_DS
-        self.delete_sql   = DELETE_RG_QUALI_DS
-        if id:
-            self.load(id)
-
-class AidObject_LB(AidObject):
-
-    def __init__(self, id=None):
-        AidObject.__init__(self, id)
-        self.category    = "LB"
-        self.category_id = 3 
-        self.page_id = 30 
-
-        self.load_sql     = LOAD_RG_LEBEN_DS 
-        self.create_sql   = CREATE_RG_LEBEN_DS
-        self.delete_sql   = DELETE_RG_LEBEN_DS
-        if id:
-            self.load(id)
-
-# vim:set ts=4 sw=4 si et sta sts=4:



More information about the Mpuls-commits mailing list