Parent Directory
|
Revision Log
- ContentGenerator.pm is now officially the superclass to all modules called by the dispatcher to generate content. - Authen.pm now has a single point of exit, which makes it easier to read, debug, and modify - Login.pm is now a subclass of ContentGenerator, and apart from the HTML, is in it's final form. - All code has been commented up - The authentication wrapper is now a working demonstration. Anyone could stick it on a webserver and try it out. The database code isn't written, so it authenticates against hardcoded strings (username: dennis, passwd: helloworld), but this at least proves that the system is workable. --Dennis
1 package WeBWorK::ContentGenerator; 2 3 # This is a superclass for Apache::WeBWorK's content generators. 4 # You are /definitely/ encouraged to read this file, since there are 5 # "abstract" functions here which show aproximately what form you would 6 # want over-ridden sub-classes to follow. go() is a particularly pertinent 7 # example. 8 9 # new(Apache::Request, WeBWorK::CourseEnvironment) 10 sub new($$$) { 11 my $proto = shift; 12 my $class = ref($proto) || $proto; 13 my $self = {}; 14 ($self->{r}, $self->{courseEnvironment}) = @_; 15 bless $self, $class; 16 return $self; 17 } 18 19 # This is a quick and dirty function to print out all (or almost all) of the 20 # fields in a form in a specified format. As you can see from the print 21 # statement, it just prints out $begining$name$middle$value$end for every 22 # field who's name doesn't match $qr_omit, a quoted regex. 23 # In it's current incarnation, it should be called from subclasses only, 24 # by saying $self->print_form_data. Of course, you could construct a 25 # hashref with ->{r} being an Apache::Request, I suppose. 26 27 sub print_form_data { 28 my ($self, $begin, $middle, $end, $qr_omit) = @_; 29 30 $r=$self->{r}; 31 my @form_data = $r->param; 32 foreach my $name (@form_data) { 33 next if ($qr_omit and $name =~ /$qr_omit/); 34 my @values = $r->param($name); 35 foreach my $value (@values) { 36 print $begin, $name, $middle, $value, $end; 37 } 38 } 39 } 40 41 # Abstract as they get, this go() is meant to be over-ridden by 42 # absolutely /anything/ that subclasses it. Most subclasses, however, 43 # will find it a useful thing to copy and modify, rather than writing from 44 # scratch. 45 46 sub go() { 47 my $self = shift; 48 $r = shift; 49 $r->content_type($ct); 50 foreach $key (keys %headers) { 51 $r->header_out($key, $headers{$key}); 52 } 53 $r->send_http_header; 54 55 return OK if $r->header_only; 56 57 print "You shouldn't see this. This is only a prototype."; 58 } 59 60 1;
| aubreyja at gmail dot com | ViewVC Help |
| Powered by ViewVC 1.0.9 |