ich mach irgendwas falsch. Weiss aber nicht was.
Code: Alles auswählen
from django.shortcuts import render_to_response
from django.core.context_processors import csrf
from django.http import HttpResponse
from django.conf import settings
from models import User
def set_cookie(response, key, value):
max_age = 5*24*60*60 #five days
expires = datetime.datetime.strftime(datetime.datetime.utcnow() + datetime.timedelta(seconds=max_age), "%a, %d-%b-%Y %H:%M:%S GMT")
response.set_cookie(key, value, max_age=max_age, expires=expires, domain=settings.SESSION_COOKIE_DOMAIN, secure=settings.SESSION_COOKIE_SECURE or None)
return response
def sysbioPortalStartApp(request):
c={}
c.update(csrf(request))
if request.method == 'POST':
if 'id' in request.COOKIES:
return render_to_response('dolleSeite1.html',c)
if request.POST.has_key('formid'):
if request.POST['FormID] == 'LoginForm':
errors=[]
n=User.objects.filter(Name__exact=request.POST['username']).count()
if n == 0:
userRowSet=User()
userRowSet.Name=request.POST['username']
userRowSet.Password=request.POST['password']
userRowSet.save()
response=render_to_response('portal.html',c)
response.set_cookie(response, 'id', 'ich')
return response
elif n == 1:
errors.append('Der Anwender existiert schon.')
return render_to_response('index.html',{'errors':errors, '':c})
elif request.POST['FormID'] == 'dataForm1ID':
return HttpResponse("Dolle Hauptseite!!!!!")
else:
return HttpResponse("Debug:nix Formular")
return render_to_response('index.html',c)
Gruss FRanky