praktikum 3
This commit is contained in:
BIN
Praktikum3/bt/app/.DS_Store
vendored
Normal file
BIN
Praktikum3/bt/app/.DS_Store
vendored
Normal file
Binary file not shown.
3
Praktikum3/bt/app/__init__.py
Executable file
3
Praktikum3/bt/app/__init__.py
Executable file
@ -0,0 +1,3 @@
|
||||
# coding: utf-8
|
||||
|
||||
# hier können Paket-Initialisierungen eingetragen werden
|
BIN
Praktikum3/bt/app/__pycache__/__init__.cpython-36.pyc
Normal file
BIN
Praktikum3/bt/app/__pycache__/__init__.cpython-36.pyc
Normal file
Binary file not shown.
BIN
Praktikum3/bt/app/__pycache__/application.cpython-36.pyc
Normal file
BIN
Praktikum3/bt/app/__pycache__/application.cpython-36.pyc
Normal file
Binary file not shown.
BIN
Praktikum3/bt/app/__pycache__/database.cpython-36.pyc
Normal file
BIN
Praktikum3/bt/app/__pycache__/database.cpython-36.pyc
Normal file
Binary file not shown.
BIN
Praktikum3/bt/app/__pycache__/error.cpython-36.pyc
Normal file
BIN
Praktikum3/bt/app/__pycache__/error.cpython-36.pyc
Normal file
Binary file not shown.
BIN
Praktikum3/bt/app/__pycache__/eval.cpython-36.pyc
Normal file
BIN
Praktikum3/bt/app/__pycache__/eval.cpython-36.pyc
Normal file
Binary file not shown.
BIN
Praktikum3/bt/app/__pycache__/navigation.cpython-36.pyc
Normal file
BIN
Praktikum3/bt/app/__pycache__/navigation.cpython-36.pyc
Normal file
Binary file not shown.
BIN
Praktikum3/bt/app/__pycache__/projekt.cpython-36.pyc
Normal file
BIN
Praktikum3/bt/app/__pycache__/projekt.cpython-36.pyc
Normal file
Binary file not shown.
BIN
Praktikum3/bt/app/__pycache__/staff.cpython-36.pyc
Normal file
BIN
Praktikum3/bt/app/__pycache__/staff.cpython-36.pyc
Normal file
Binary file not shown.
BIN
Praktikum3/bt/app/__pycache__/templates.cpython-36.pyc
Normal file
BIN
Praktikum3/bt/app/__pycache__/templates.cpython-36.pyc
Normal file
Binary file not shown.
121
Praktikum3/bt/app/application.py
Executable file
121
Praktikum3/bt/app/application.py
Executable file
@ -0,0 +1,121 @@
|
||||
# coding: utf-8
|
||||
|
||||
import json
|
||||
|
||||
import cherrypy
|
||||
|
||||
from .projekt import Projekt_cl, ProjektKomponenten_cl, Komponente_cl
|
||||
from .staff import QsMitarbeiter_cl, SwEntwickler_cl
|
||||
from .error import KatFehler_cl, KatUrsache_cl, Fehler_cl
|
||||
from .eval import ProList_cl, KatList_cl
|
||||
|
||||
#----------------------------------------------------------
|
||||
class Application_cl(object):
|
||||
#----------------------------------------------------------
|
||||
|
||||
exposed = True # gilt für alle Methoden
|
||||
|
||||
#-------------------------------------------------------
|
||||
def __init__(self):
|
||||
#-------------------------------------------------------
|
||||
self.handler_o = {
|
||||
'projekt': Projekt_cl(),
|
||||
'projektkomponenten': ProjektKomponenten_cl(),
|
||||
'komponente': Komponente_cl(),
|
||||
|
||||
'qsmitarbeiter': QsMitarbeiter_cl(),
|
||||
'swentwickler': SwEntwickler_cl(),
|
||||
|
||||
'katfehler': KatFehler_cl(),
|
||||
'katursache': KatUrsache_cl(),
|
||||
'fehler': Fehler_cl(),
|
||||
|
||||
'prolist': ProList_cl(),
|
||||
'katlist': KatList_cl()
|
||||
}
|
||||
|
||||
# es wird keine index-Methode vorgesehen, weil stattdessen
|
||||
# die Webseite index.html ausgeliefert wird (siehe Konfiguration)
|
||||
|
||||
#-------------------------------------------------------
|
||||
def GET(self, path_spl = 'projekt', id=None):
|
||||
#-------------------------------------------------------
|
||||
retVal_o = {
|
||||
'data': None
|
||||
}
|
||||
|
||||
if path_spl in self.handler_o:
|
||||
retVal_o = self.handler_o[path_spl].GET(id)
|
||||
|
||||
if retVal_o['data'] == None:
|
||||
cherrypy.response.status = 404
|
||||
|
||||
return json.dumps(retVal_o)
|
||||
|
||||
#-------------------------------------------------------
|
||||
def POST(self, path_spl = 'projekt', **data_opl):
|
||||
#-------------------------------------------------------
|
||||
retVal_o = {
|
||||
'id': None
|
||||
}
|
||||
|
||||
# data_opl: Dictionary mit den gelieferten key-value-Paaren
|
||||
|
||||
# hier müsste man prüfen, ob die Daten korrekt vorliegen!
|
||||
|
||||
if path_spl in self.handler_o:
|
||||
retVal_o = self.handler_o[path_spl].POST(data_opl)
|
||||
|
||||
if retVal_o['id'] == None:
|
||||
cherrypy.response.status = 409
|
||||
|
||||
return json.dumps(retVal_o)
|
||||
|
||||
#-------------------------------------------------------
|
||||
def PUT(self, path_spl = 'projekt', **data_opl):
|
||||
#-------------------------------------------------------
|
||||
# Sichern der Daten: jetzt wird keine vollständige Seite
|
||||
# zurückgeliefert, sondern nur noch die Information, ob das
|
||||
# Speichern erfolgreich war
|
||||
|
||||
retVal_o = {
|
||||
'id': None
|
||||
}
|
||||
|
||||
# data_opl: Dictionary mit den gelieferten key-value-Paaren
|
||||
# hier müsste man prüfen, ob die Daten korrekt vorliegen!
|
||||
|
||||
if path_spl in self.handler_o:
|
||||
retVal_o = self.handler_o[path_spl].PUT(data_opl)
|
||||
|
||||
if retVal_o['id'] == None:
|
||||
cherrypy.response.status = 404
|
||||
|
||||
return json.dumps(retVal_o)
|
||||
|
||||
#-------------------------------------------------------
|
||||
def DELETE(self, path_spl = 'projekt', id=None):
|
||||
#-------------------------------------------------------
|
||||
# Eintrag löschen, nur noch Rückmeldung liefern
|
||||
retVal_o = {
|
||||
'id': id
|
||||
}
|
||||
|
||||
if path_spl in self.handler_o:
|
||||
retVal_o = self.handler_o[path_spl].DELETE(id)
|
||||
|
||||
if retVal_o['id'] == None:
|
||||
cherrypy.response.status = 404
|
||||
|
||||
return json.dumps(retVal_o)
|
||||
|
||||
#-------------------------------------------------------
|
||||
def default(self, *arguments, **kwargs):
|
||||
#-------------------------------------------------------
|
||||
msg_s = "unbekannte Anforderung: " + \
|
||||
str(arguments) + \
|
||||
' ' + \
|
||||
str(kwargs)
|
||||
raise cherrypy.HTTPError(404, msg_s)
|
||||
|
||||
# EOF
|
256
Praktikum3/bt/app/database.py
Executable file
256
Praktikum3/bt/app/database.py
Executable file
@ -0,0 +1,256 @@
|
||||
# coding: utf-8
|
||||
|
||||
import os
|
||||
import os.path
|
||||
import codecs
|
||||
|
||||
import json
|
||||
|
||||
#----------------------------------------------------------
|
||||
class Database_cl(object):
|
||||
#----------------------------------------------------------
|
||||
|
||||
# Daten in dieser Variante dauerhaft (persistent) speichern
|
||||
# dazu jedes Element in einer Datei, die entsprechend der id benannt ist, speichern
|
||||
# alle Elemente werden zur Laufzeit des Servers zur Vereinfachung auch im
|
||||
# Hauptspeicher abgelegt
|
||||
|
||||
# die nächste zu vergebende Id wird ebenfalls dauerhaft gespeichert
|
||||
|
||||
# zur Vereinfachung wird hier fest vorgegebenen, dass sich die Daten
|
||||
# im Unterverzeichnis "data/<type>" befinden (siehe Konstruktor)
|
||||
|
||||
# es wird ferner angenommen, dass die Datei "data/<type>/maxid.dat" bereits existiert
|
||||
# und als einzigen Eintrag den aktuellen Wert der maximalen Id enthält
|
||||
|
||||
#-------------------------------------------------------
|
||||
def __init__(self, type_spl):
|
||||
#-------------------------------------------------------
|
||||
self.type_s = type_spl
|
||||
self.path_s = os.path.join('data', type_spl)
|
||||
self.data_o = {}
|
||||
self.readData_p()
|
||||
|
||||
#-------------------------------------------------------
|
||||
def create_px(self, data_opl):
|
||||
#-------------------------------------------------------
|
||||
# Überprüfung der Datenn müsste ergänzt werden!
|
||||
id_s = self.nextId_p()
|
||||
# Datei erzeugen
|
||||
file_o = codecs.open(os.path.join(self.path_s , id_s+'.dat'), 'w', 'utf-8')
|
||||
file_o.write(json.dumps(data_opl, indent=3, ensure_ascii=True))
|
||||
file_o.close()
|
||||
|
||||
self.data_o[id_s] = data_opl
|
||||
|
||||
return id_s
|
||||
|
||||
#-------------------------------------------------------
|
||||
def read_px(self, id_spl = None):
|
||||
#-------------------------------------------------------
|
||||
# hier zur Vereinfachung:
|
||||
# Aufruf ohne id: alle Einträge liefern
|
||||
data_o = None
|
||||
if id_spl == None:
|
||||
data_o = self.data_o
|
||||
elif id_spl == '0':
|
||||
data_o = self.getDefault_px()
|
||||
else:
|
||||
if id_spl in self.data_o:
|
||||
data_o = self.data_o[id_spl]
|
||||
|
||||
return data_o
|
||||
|
||||
#-------------------------------------------------------
|
||||
def update_px(self, id_spl, data_opl):
|
||||
#-------------------------------------------------------
|
||||
# Überprüfung der Daten müsste ergänzt werden!
|
||||
status_b = False
|
||||
if id_spl in self.data_o:
|
||||
# Datei aktualisieren
|
||||
file_o = codecs.open(os.path.join(self.path_s, id_spl+'.dat'), 'w', 'utf-8')
|
||||
file_o.write(json.dumps(data_opl, indent=3, ensure_ascii=True))
|
||||
file_o.close()
|
||||
|
||||
self.data_o[id_spl] = data_opl
|
||||
status_b = True
|
||||
|
||||
return status_b
|
||||
|
||||
#-------------------------------------------------------
|
||||
def delete_px(self, id_spl):
|
||||
#-------------------------------------------------------
|
||||
status_b = False
|
||||
if id_spl in self.data_o:
|
||||
# Datei entfernen
|
||||
os.remove(os.path.join(self.path_s, id_spl+'.dat'))
|
||||
|
||||
del self.data_o[id_spl]
|
||||
status_b = True
|
||||
|
||||
return status_b
|
||||
|
||||
#-------------------------------------------------------
|
||||
def getDefault_px(self):
|
||||
#-------------------------------------------------------
|
||||
# sollte überschrieben werden!
|
||||
return {}
|
||||
|
||||
#-------------------------------------------------------
|
||||
def readData_p(self):
|
||||
#-------------------------------------------------------
|
||||
|
||||
files_a = os.listdir(self.path_s)
|
||||
for fileName_s in files_a:
|
||||
if fileName_s.endswith('.dat') and fileName_s != 'maxid.dat':
|
||||
file_o = codecs.open(os.path.join(self.path_s, fileName_s), 'rU', 'utf-8')
|
||||
content_s = file_o.read()
|
||||
file_o.close()
|
||||
id_s = fileName_s[:-4]
|
||||
self.data_o[id_s] = json.loads(content_s)
|
||||
|
||||
#-------------------------------------------------------
|
||||
def nextId_p(self):
|
||||
#-------------------------------------------------------
|
||||
file_o = open(os.path.join(self.path_s, 'maxid.dat'), 'r+')
|
||||
maxId_s = file_o.read()
|
||||
maxId_s = str(int(maxId_s)+1)
|
||||
file_o.seek(0)
|
||||
file_o.write(maxId_s)
|
||||
file_o.close()
|
||||
|
||||
return maxId_s
|
||||
|
||||
#----------------------------------------------------------
|
||||
class ProjektDatabase_cl(Database_cl):
|
||||
#----------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------
|
||||
def __init__(self):
|
||||
#-------------------------------------------------------
|
||||
super().__init__('projekt')
|
||||
|
||||
#-------------------------------------------------------
|
||||
def getDefault_px(self):
|
||||
#-------------------------------------------------------
|
||||
|
||||
return {
|
||||
'name': '',
|
||||
'id': ''
|
||||
}
|
||||
|
||||
#----------------------------------------------------------
|
||||
class KomponenteDatabase_cl(Database_cl):
|
||||
#----------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------
|
||||
def __init__(self):
|
||||
#-------------------------------------------------------
|
||||
super().__init__('komponente')
|
||||
|
||||
#-------------------------------------------------------
|
||||
def getDefault_px(self):
|
||||
#-------------------------------------------------------
|
||||
|
||||
return {
|
||||
'name': '',
|
||||
'id': '',
|
||||
'projekt-id': ''
|
||||
}
|
||||
|
||||
#----------------------------------------------------------
|
||||
class QsMitarbeiterDatabase_cl(Database_cl):
|
||||
#----------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------
|
||||
def __init__(self):
|
||||
#-------------------------------------------------------
|
||||
super().__init__('qsmitarbeiter')
|
||||
|
||||
#-------------------------------------------------------
|
||||
def getDefault_px(self):
|
||||
#-------------------------------------------------------
|
||||
|
||||
return {
|
||||
'name': '',
|
||||
'id': ''
|
||||
}
|
||||
|
||||
#----------------------------------------------------------
|
||||
class SwEntwicklerDatabase_cl(Database_cl):
|
||||
#----------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------
|
||||
def __init__(self):
|
||||
#-------------------------------------------------------
|
||||
super().__init__('swentwickler')
|
||||
|
||||
#-------------------------------------------------------
|
||||
def getDefault_px(self):
|
||||
#-------------------------------------------------------
|
||||
|
||||
return {
|
||||
'name': '',
|
||||
'id': ''
|
||||
}
|
||||
|
||||
#----------------------------------------------------------
|
||||
class KatfehlerDatabase_cl(Database_cl):
|
||||
#----------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------
|
||||
def __init__(self):
|
||||
#-------------------------------------------------------
|
||||
super().__init__('katfehler')
|
||||
|
||||
#-------------------------------------------------------
|
||||
def getDefault_px(self):
|
||||
#-------------------------------------------------------
|
||||
|
||||
return {
|
||||
'name': '',
|
||||
'id': ''
|
||||
}
|
||||
|
||||
#----------------------------------------------------------
|
||||
class KatursacheDatabase_cl(Database_cl):
|
||||
#----------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------
|
||||
def __init__(self):
|
||||
#-------------------------------------------------------
|
||||
super().__init__('katursache')
|
||||
|
||||
#-------------------------------------------------------
|
||||
def getDefault_px(self):
|
||||
#-------------------------------------------------------
|
||||
|
||||
return {
|
||||
'name': '',
|
||||
'id': ''
|
||||
}
|
||||
|
||||
#----------------------------------------------------------
|
||||
class FehlerDatabase_cl(Database_cl):
|
||||
#----------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------
|
||||
def __init__(self):
|
||||
#-------------------------------------------------------
|
||||
super().__init__('fehler')
|
||||
|
||||
#-------------------------------------------------------
|
||||
def getDefault_px(self):
|
||||
#-------------------------------------------------------
|
||||
|
||||
return {
|
||||
'name': '',
|
||||
'id': '',
|
||||
'komponente-id': '',
|
||||
'katfehler-id': '',
|
||||
'katursache-id': '',
|
||||
'qsmitarbeiter-id': '',
|
||||
'swentwickler-id': '',
|
||||
'status': 'offen'
|
||||
}
|
||||
# EOF
|
140
Praktikum3/bt/app/error.py
Normal file
140
Praktikum3/bt/app/error.py
Normal file
@ -0,0 +1,140 @@
|
||||
# coding: utf-8
|
||||
|
||||
import json
|
||||
|
||||
import cherrypy
|
||||
#from .database import SourceDatabase_cl, EvaluatedDatabase_cl
|
||||
# Method-Dispatching!
|
||||
|
||||
# Übersicht Anforderungen / Methoden
|
||||
# (beachte: / relativ zu /navigation, siehe Konfiguration Server!)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Anforderung GET PUT POST DELETE
|
||||
-----------------------------------------------------------------------------------------
|
||||
/katfehler/ alle Fehlerkategorien
|
||||
/katfehler/:katfehler-id
|
||||
einzelne Fehlerkategorien Fehler löschen
|
||||
/katfehler/+Daten neue FK speichern
|
||||
/katfehler/:katfehler-id+Daten Fehler ändern
|
||||
"""
|
||||
|
||||
#----------------------------------------------------------
|
||||
class KatFehler_cl(object):
|
||||
#----------------------------------------------------------
|
||||
|
||||
exposed = True # gilt für alle Methoden
|
||||
|
||||
#-------------------------------------------------------
|
||||
def __init__(self):
|
||||
#-------------------------------------------------------
|
||||
pass
|
||||
|
||||
#-------------------------------------------------------
|
||||
def GET(self):
|
||||
#-------------------------------------------------------
|
||||
return json.dumps(retVal_o)
|
||||
|
||||
#-------------------------------------------------------
|
||||
def PUT(self):
|
||||
#-------------------------------------------------------
|
||||
return json.dumps(retVal_o)
|
||||
|
||||
#-------------------------------------------------------
|
||||
def POST(self):
|
||||
#-------------------------------------------------------
|
||||
return json.dumps(retVal_o)
|
||||
|
||||
#-------------------------------------------------------
|
||||
def DELETE(self):
|
||||
#-------------------------------------------------------
|
||||
return json.dumps(retVal_o)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Anforderung GET PUT POST DELETE
|
||||
-----------------------------------------------------------------------------------------
|
||||
/katursache/ alle Fehlerkategorien
|
||||
/katursache/:katursache-id
|
||||
einzelne Fehlerkategorien Fehler löschen
|
||||
/katursache/+Daten neue FK speichern
|
||||
/katursache/:katursache-id+Daten Fehler ändern
|
||||
"""
|
||||
|
||||
#----------------------------------------------------------
|
||||
class KatUrsache_cl(object):
|
||||
#----------------------------------------------------------
|
||||
|
||||
exposed = True # gilt für alle Methoden
|
||||
|
||||
#-------------------------------------------------------
|
||||
def __init__(self):
|
||||
#-------------------------------------------------------
|
||||
pass
|
||||
|
||||
#-------------------------------------------------------
|
||||
def GET(self):
|
||||
#-------------------------------------------------------
|
||||
return json.dumps(retVal_o)
|
||||
|
||||
#-------------------------------------------------------
|
||||
def PUT(self):
|
||||
#-------------------------------------------------------
|
||||
return json.dumps(retVal_o)
|
||||
|
||||
#-------------------------------------------------------
|
||||
def POST(self):
|
||||
#-------------------------------------------------------
|
||||
return json.dumps(retVal_o)
|
||||
|
||||
#-------------------------------------------------------
|
||||
def DELETE(self):
|
||||
#-------------------------------------------------------
|
||||
return json.dumps(retVal_o)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Anforderung GET PUT POST DELETE
|
||||
-----------------------------------------------------------------------------------------
|
||||
/fehler/ alle Fehler
|
||||
/fehler/?type=erkannt alle erkannten Fehler
|
||||
/fehler/?type=behoben alle behobenen Fehler
|
||||
/fehler/:fehler-id einzelner Fehler
|
||||
/fehler/+Daten Fehler speichern
|
||||
Rückgabe Id
|
||||
/fehler/:fehler-id+Daten Fehler ändern
|
||||
|
||||
"""
|
||||
|
||||
#----------------------------------------------------------
|
||||
class Fehler_cl(object):
|
||||
#----------------------------------------------------------
|
||||
|
||||
exposed = True # gilt für alle Methoden
|
||||
|
||||
#-------------------------------------------------------
|
||||
def __init__(self):
|
||||
#-------------------------------------------------------
|
||||
pass
|
||||
|
||||
#-------------------------------------------------------
|
||||
def GET(self):
|
||||
#-------------------------------------------------------
|
||||
return json.dumps(retVal_o)
|
||||
|
||||
#-------------------------------------------------------
|
||||
def PUT(self):
|
||||
#-------------------------------------------------------
|
||||
return json.dumps(retVal_o)
|
||||
|
||||
#-------------------------------------------------------
|
||||
def POST(self):
|
||||
#-------------------------------------------------------
|
||||
return json.dumps(retVal_o)
|
||||
|
||||
|
||||
# EOF
|
64
Praktikum3/bt/app/eval.py
Normal file
64
Praktikum3/bt/app/eval.py
Normal file
@ -0,0 +1,64 @@
|
||||
# coding: utf-8
|
||||
|
||||
import json
|
||||
|
||||
import cherrypy
|
||||
#from .database import SourceDatabase_cl, EvaluatedDatabase_cl
|
||||
# Method-Dispatching!
|
||||
|
||||
# Übersicht Anforderungen / Methoden
|
||||
# (beachte: / relativ zu /navigation, siehe Konfiguration Server!)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Anforderung GET PUT POST DELETE
|
||||
-----------------------------------------------------------------------------------------
|
||||
/prolist/ Auswertung nach
|
||||
Projekt/Komponente/
|
||||
Status
|
||||
"""
|
||||
|
||||
#----------------------------------------------------------
|
||||
class ProList_cl(object):
|
||||
#----------------------------------------------------------
|
||||
|
||||
exposed = True # gilt für alle Methoden
|
||||
|
||||
#-------------------------------------------------------
|
||||
def __init__(self):
|
||||
#-------------------------------------------------------
|
||||
pass
|
||||
|
||||
#-------------------------------------------------------
|
||||
def GET(self):
|
||||
#-------------------------------------------------------
|
||||
return json.dumps(retVal_o)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Anforderung GET PUT POST DELETE
|
||||
-----------------------------------------------------------------------------------------
|
||||
/katlist/ Auswertung nach
|
||||
Kategorie/Status
|
||||
"""
|
||||
|
||||
#----------------------------------------------------------
|
||||
class KatList_cl(object):
|
||||
#----------------------------------------------------------
|
||||
|
||||
exposed = True # gilt für alle Methoden
|
||||
|
||||
#-------------------------------------------------------
|
||||
def __init__(self):
|
||||
#-------------------------------------------------------
|
||||
pass
|
||||
|
||||
#-------------------------------------------------------
|
||||
def GET(self):
|
||||
#-------------------------------------------------------
|
||||
return json.dumps(retVal_o)
|
||||
|
||||
|
||||
# EOF
|
47
Praktikum3/bt/app/navigation.py
Executable file
47
Praktikum3/bt/app/navigation.py
Executable file
@ -0,0 +1,47 @@
|
||||
# coding: utf-8
|
||||
|
||||
import json
|
||||
|
||||
import cherrypy
|
||||
|
||||
# Method-Dispatching!
|
||||
|
||||
# Übersicht Anforderungen / Methoden
|
||||
# (beachte: / relativ zu /navigation, siehe Konfiguration Server!)
|
||||
|
||||
"""
|
||||
|
||||
Anforderung GET PUT POST DELETE
|
||||
----------------------------------------------------------------
|
||||
/ Nav-Entries - - -
|
||||
|
||||
"""
|
||||
|
||||
#----------------------------------------------------------
|
||||
class Navigation_cl(object):
|
||||
#----------------------------------------------------------
|
||||
|
||||
exposed = True # gilt für alle Methoden
|
||||
|
||||
#-------------------------------------------------------
|
||||
def __init__(self):
|
||||
#-------------------------------------------------------
|
||||
pass
|
||||
|
||||
#-------------------------------------------------------
|
||||
def GET(self):
|
||||
#-------------------------------------------------------
|
||||
# Hinweis: könnte man auch aus einer Datei einlesen
|
||||
retVal_o = [
|
||||
{'action': 'modError' , 'text': 'Bearbeitung Fehlerdaten'},
|
||||
{'action': 'modProj' , 'text': 'Pflege Projekte'},
|
||||
{'action': 'modComp' , 'text': 'Pflege Komponenten'},
|
||||
{'action': 'modStaff' , 'text': 'Pflege Daten Mitarbeiter'},
|
||||
{'action': 'modCat' , 'text': 'Pflege Kategorien'},
|
||||
{'action': 'evalProj' , 'text': 'Auswertung Projekte/Fehler'},
|
||||
{'action': 'evalCat' , 'text': 'Auswertung Kategorien/Fehler'}
|
||||
]
|
||||
|
||||
return json.dumps(retVal_o)
|
||||
|
||||
# EOF
|
181
Praktikum3/bt/app/projekt.py
Normal file
181
Praktikum3/bt/app/projekt.py
Normal file
@ -0,0 +1,181 @@
|
||||
# coding: utf-8
|
||||
|
||||
import json
|
||||
|
||||
import cherrypy
|
||||
from .database import ProjektDatabase_cl, KomponenteDatabase_cl
|
||||
# Method-Dispatching!
|
||||
|
||||
# Übersicht Anforderungen / Methoden
|
||||
# (beachte: / relativ zu /navigation, siehe Konfiguration Server!)
|
||||
|
||||
|
||||
#-------------------------------------------------------
|
||||
def adjustId_p(id_spl, data_opl):
|
||||
#-------------------------------------------------------
|
||||
|
||||
if id_spl == None:
|
||||
data_opl['id'] = ''
|
||||
elif id_spl == '':
|
||||
data_opl['id'] = ''
|
||||
elif id_spl == '0':
|
||||
data_opl['id'] = ''
|
||||
else:
|
||||
data_opl['id'] = id_spl
|
||||
return data_opl
|
||||
|
||||
|
||||
"""
|
||||
Anforderung GET PUT POST DELETE
|
||||
-----------------------------------------------------------------------------------------
|
||||
/projekt/ alle Projekte
|
||||
(Liste) anfordern
|
||||
/projekt/:projekt-id einzelnes Projekt Projekt löschen
|
||||
anfordern
|
||||
/projekt/+Daten neues speichern
|
||||
Projekt-Id Rückgabe
|
||||
/projekt/:projekt-id+Daten Projekt ändern
|
||||
"""
|
||||
|
||||
#----------------------------------------------------------
|
||||
class Projekt_cl(object):
|
||||
#----------------------------------------------------------
|
||||
|
||||
exposed = True # gilt für alle Methoden
|
||||
|
||||
#-------------------------------------------------------
|
||||
def __init__(self):
|
||||
#-------------------------------------------------------
|
||||
self.db_o = ProjektDatabase_cl()
|
||||
|
||||
#-------------------------------------------------------
|
||||
def GET(self, id = None):
|
||||
#-------------------------------------------------------
|
||||
retVal_o = {
|
||||
'data': None
|
||||
}
|
||||
if id == None:
|
||||
# Anforderung der Liste
|
||||
retVal_o['data'] = self.db_o.read_px()
|
||||
else:
|
||||
# Anforderung eines Dokuments
|
||||
data_o = self.db_o.read_px(id)
|
||||
if data_o != None:
|
||||
retVal_o['data'] = adjustId_p(id, data_o)
|
||||
|
||||
return retVal_o
|
||||
#return json.dumps(retVal_o)
|
||||
|
||||
#-------------------------------------------------------
|
||||
def PUT(self):
|
||||
#-------------------------------------------------------
|
||||
return json.dumps(retVal_o)
|
||||
|
||||
#-------------------------------------------------------
|
||||
def POST(self):
|
||||
#-------------------------------------------------------
|
||||
return json.dumps(retVal_o)
|
||||
|
||||
#-------------------------------------------------------
|
||||
def DELETE(self):
|
||||
#-------------------------------------------------------
|
||||
return json.dumps(retVal_o)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Anforderung GET PUT POST DELETE
|
||||
-----------------------------------------------------------------------------------------
|
||||
/projektkomponenten/:projekt-id
|
||||
Komponenten liefern
|
||||
"""
|
||||
|
||||
#----------------------------------------------------------
|
||||
class ProjektKomponenten_cl(object):
|
||||
#----------------------------------------------------------
|
||||
|
||||
exposed = True # gilt für alle Methoden
|
||||
|
||||
#-------------------------------------------------------
|
||||
def __init__(self):
|
||||
#-------------------------------------------------------
|
||||
self.db_o = KomponenteDatabase_cl()
|
||||
|
||||
#-------------------------------------------------------
|
||||
def GET(self):
|
||||
#-------------------------------------------------------
|
||||
retVal_o = {
|
||||
'data': None
|
||||
}
|
||||
if id == None:
|
||||
# Anforderung der Liste
|
||||
retVal_o['data'] = self.db_o.read_px()
|
||||
else:
|
||||
# Anforderung eines Dokuments
|
||||
data_o = self.db_o.read_px(id)
|
||||
if data_o != None:
|
||||
retVal_o['data'] = adjustId_p(id, data_o)
|
||||
|
||||
return retVal_o
|
||||
#return json.dumps(retVal_o)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Anforderung GET PUT POST DELETE
|
||||
-----------------------------------------------------------------------------------------
|
||||
/komponente/ alle Komponenten
|
||||
/komponente/:komponente-id
|
||||
einzelne Komponente Komponente löschen
|
||||
/komponente/:projekt-id+Daten neue Komponente speichern
|
||||
Id Rückgabe
|
||||
/komponente/:komponente-id+Daten Komponente ändern
|
||||
"""
|
||||
|
||||
#----------------------------------------------------------
|
||||
class Komponente_cl(object):
|
||||
#----------------------------------------------------------
|
||||
|
||||
exposed = True # gilt für alle Methoden
|
||||
|
||||
#-------------------------------------------------------
|
||||
def __init__(self):
|
||||
#-------------------------------------------------------
|
||||
self.db_o = KomponenteDatabase_cl()
|
||||
|
||||
#-------------------------------------------------------
|
||||
def GET(self):
|
||||
#-------------------------------------------------------
|
||||
retVal_o = {
|
||||
'data': None
|
||||
}
|
||||
if id == None:
|
||||
# Anforderung der Liste
|
||||
retVal_o['data'] = self.db_o.read_px()
|
||||
else:
|
||||
# Anforderung eines Dokuments
|
||||
data_o = self.db_o.read_px(id)
|
||||
if data_o != None:
|
||||
retVal_o['data'] = adjustId_p(id, data_o)
|
||||
|
||||
return retVal_o
|
||||
#return json.dumps(retVal_o)
|
||||
|
||||
#-------------------------------------------------------
|
||||
def PUT(self):
|
||||
#-------------------------------------------------------
|
||||
return json.dumps(retVal_o)
|
||||
|
||||
#-------------------------------------------------------
|
||||
def POST(self):
|
||||
#-------------------------------------------------------
|
||||
return json.dumps(retVal_o)
|
||||
|
||||
#-------------------------------------------------------
|
||||
def DELETE(self):
|
||||
#-------------------------------------------------------
|
||||
return json.dumps(retVal_o)
|
||||
|
||||
|
||||
# EOF
|
||||
|
100
Praktikum3/bt/app/staff.py
Normal file
100
Praktikum3/bt/app/staff.py
Normal file
@ -0,0 +1,100 @@
|
||||
# coding: utf-8
|
||||
|
||||
import json
|
||||
|
||||
import cherrypy
|
||||
#from .database import SourceDatabase_cl, EvaluatedDatabase_cl
|
||||
# Method-Dispatching!
|
||||
|
||||
# Übersicht Anforderungen / Methoden
|
||||
# (beachte: / relativ zu /navigation, siehe Konfiguration Server!)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Anforderung GET PUT POST DELETE
|
||||
-----------------------------------------------------------------------------------------
|
||||
/qsmitarbeiter/ alle Daten anfordern
|
||||
/qsmitarbeiter/:mitarbeiter-id
|
||||
Daten eines einzelnen Mitarbeiters
|
||||
/qsmitarbeiter/+Daten Daten speichern
|
||||
Rückgabe Id
|
||||
/qsmitarbeiter/:qsmitarbeiter-id+Daten Daten ändern
|
||||
/qsmitarbeiter/:qsmitarbeiter-id Daten löschen
|
||||
"""
|
||||
|
||||
#----------------------------------------------------------
|
||||
class QsMitarbeiter_cl(object):
|
||||
#----------------------------------------------------------
|
||||
|
||||
exposed = True # gilt für alle Methoden
|
||||
|
||||
#-------------------------------------------------------
|
||||
def __init__(self):
|
||||
#-------------------------------------------------------
|
||||
pass
|
||||
|
||||
#-------------------------------------------------------
|
||||
def GET(self):
|
||||
#-------------------------------------------------------
|
||||
return json.dumps(retVal_o)
|
||||
|
||||
#-------------------------------------------------------
|
||||
def PUT(self):
|
||||
#-------------------------------------------------------
|
||||
return json.dumps(retVal_o)
|
||||
|
||||
#-------------------------------------------------------
|
||||
def POST(self):
|
||||
#-------------------------------------------------------
|
||||
return json.dumps(retVal_o)
|
||||
|
||||
#-------------------------------------------------------
|
||||
def DELETE(self):
|
||||
#-------------------------------------------------------
|
||||
return json.dumps(retVal_o)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Anforderung GET PUT POST DELETE
|
||||
-----------------------------------------------------------------------------------------
|
||||
/swentwickler/ Daten aller Entwickler
|
||||
/swentwickler/:swentwickler-id
|
||||
Daten eines einzelnen Entwicklers Daten löschen
|
||||
/swentwickler/+Daten Neuen SW-E speichern
|
||||
/swentwickler/:swentwickler-id+Daten Daten ändern
|
||||
"""
|
||||
|
||||
#----------------------------------------------------------
|
||||
class SwEntwickler_cl(object):
|
||||
#----------------------------------------------------------
|
||||
|
||||
exposed = True # gilt für alle Methoden
|
||||
|
||||
#-------------------------------------------------------
|
||||
def __init__(self):
|
||||
#-------------------------------------------------------
|
||||
pass
|
||||
|
||||
#-------------------------------------------------------
|
||||
def GET(self):
|
||||
#-------------------------------------------------------
|
||||
return json.dumps(retVal_o)
|
||||
|
||||
#-------------------------------------------------------
|
||||
def PUT(self):
|
||||
#-------------------------------------------------------
|
||||
return json.dumps(retVal_o)
|
||||
|
||||
#-------------------------------------------------------
|
||||
def POST(self):
|
||||
#-------------------------------------------------------
|
||||
return json.dumps(retVal_o)
|
||||
|
||||
#-------------------------------------------------------
|
||||
def DELETE(self):
|
||||
#-------------------------------------------------------
|
||||
return json.dumps(retVal_o)
|
||||
|
||||
# EOF
|
52
Praktikum3/bt/app/templates.py
Executable file
52
Praktikum3/bt/app/templates.py
Executable file
@ -0,0 +1,52 @@
|
||||
# coding: utf-8
|
||||
|
||||
import json
|
||||
|
||||
import os
|
||||
import codecs
|
||||
|
||||
import cherrypy
|
||||
|
||||
# Method-Dispatching!
|
||||
|
||||
# Übersicht Anforderungen / Methoden
|
||||
# (beachte: / relativ zu /template, siehe Konfiguration Server!)
|
||||
|
||||
"""
|
||||
|
||||
Anforderung GET PUT POST DELETE
|
||||
----------------------------------------------------------------
|
||||
/ Alle - - -
|
||||
Templates
|
||||
liefern
|
||||
|
||||
"""
|
||||
|
||||
#----------------------------------------------------------
|
||||
class Templates_cl(object):
|
||||
#----------------------------------------------------------
|
||||
|
||||
exposed = True # gilt für alle Methoden
|
||||
|
||||
#-------------------------------------------------------
|
||||
def __init__(self):
|
||||
#-------------------------------------------------------
|
||||
pass
|
||||
|
||||
#-------------------------------------------------------
|
||||
def GET(self):
|
||||
#-------------------------------------------------------
|
||||
retVal_o = {
|
||||
'templates': {}
|
||||
}
|
||||
|
||||
files_a = os.listdir('templates')
|
||||
for fileName_s in files_a:
|
||||
file_o = codecs.open(os.path.join('templates', fileName_s), 'rU', 'utf-8')
|
||||
content_s = file_o.read()
|
||||
file_o.close()
|
||||
retVal_o["templates"][fileName_s] = content_s
|
||||
|
||||
return json.dumps(retVal_o)
|
||||
|
||||
# EOF
|
Reference in New Issue
Block a user