well -- I hit the wrong key and posted that before I was finished typing... 

here's what's in my views.py file:
def index(request)
     current_username = os.environ['REMOTE_USER']

This should provide me with their username (yes I do have 'import os' at 
the top of the file)...

Now, after I get their username I want to do something like this (but I'm 
not sure how to write in django -- so I've put ## around the pseudo-code)
     try:
         student = Student.objects.get(student_name=current_username)
     except (#can't find it in Student database, but I don't know what code 
to put here#)
         try:
             instructor = 
Instructor.objects.get(instructor_name=current_username)
         except (#can't find it in Instructor database, but I don't know 
what code to put here#)
               try:
                    administrator = 
Administrator.objects.get(administrator_name=current_username)
               except (#fail condition - can't find current_username in 
Administrator database, but I don't know what code to put here#)
                    #because we failed to find it in any database, we 
assume it's a student and add it
                    student = Student(student_name=current_username)
                    student.save
     #here's where I'm not sure how to continue -- I want to do something 
like this#
     #if student is defined#
          return render_to_response('ta/student.html', student)
     #else if instructor is defined#
          return render_to_response('ta/instructor.html', instructor)
     #else if administrator is defined#
          return render_to_response('ta/administrator.html', administrator)
#end of my code#

So -- can someone please help me fill in the missing code above?  I've been 
searching for hours, but I just can't seem to hit on the correct 
search-terms to get done what I want here...

Thanks,
Laurence MacNeill
Mableton, Georgia, USA


On Monday, June 18, 2012 3:40:53 AM UTC-4, Laurence MacNeill wrote:
>
> Ok, I'm a total django noob here, so I am probably doing this wrong...  
> But here goes...
>
> When someone comes to my django app's root (index), I need to verify their 
> user-name (which is stored in a Linux environment variable).  Based on 
> where (or if) I find their user-name, I want to send them to one of three 
> different pages -- if I don't find them in any database, I want to add them 
> to a given database, then send them to a page.
>
> So here's what I have in my views.py file:
> def index(request)
>      current_username = os.environ['REMOTE_USER']
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/rVfs691Nk0AJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to