May 21, 2002, 2:01 PM
Post #1 of 2
CGI - The other way round...
I would like to program a Perl module which offers another way to program CGI-Applications.
(As a Semester Project)
The programmer should be able to abstract the hole task of :
- presenting a form to the user (HTML-Generation)
- doing sanity checks on the input (Form-Processing)
- presenting the form again, if errors are found, etc...
in a sub-routine call. (The formdata could be seen as the return value of the subroutine.)
Of course if the user posts the data, it will restart the entire script. So my Module would
basically provide a way to the programmer to "resume" the script where is left of.
(INSIDE the subroutine that generated the form.)
Lets assume I use sessions to save all the needed data between requests.
There are two major problems,and i have no idea how to solve them.
Perhaps one of the Perl-Gurus out there have a hint or two ;-)
Each time a HTML-Page is send to the user, the programmer would call the function State::Save.
Somehow the State Module must then be able to gather all information about the interpreters state
(stack, lexical and global variables), and save it in a persistent session. Then, State::Save() simply exits.
Problem 1: How does one access the stack and all the variables (Inside Perl / XS) ?
The user sends then the filled in form back (Post/Get), and the script gets started again.
The State Module should intercept execution immediately with a BEGIN block and check
if the requests session has state-data. If so, the module has to restore the stack and variables,
then it has to resume execution where it left of.
Problem 2: How does one manipulate the stack (Inside Perl / XS ) ?
Once the Stack is restored, I assume, I could use the special Syntax used by AUTOLOAD to jump
directly inside the State::Save routine, which would this time return directly to the calling user routine.
There, the user routine could begin with some form checking, value parsing, an would end up returning the
formdata to the application.
Is this possible at all ? performance problems ?
Thank you for thoughts, implementation ideas and comments.
Communication Systems Student