|
WebKeystone Lesson 3-1: Using temporary storage
There are several methods available for storage and retrieval of information in your WebKeystone application. You have access to temporary storage, as well as three types of long-term storage, each of which has its own advantages and special uses. You choose the type of storage that best suits your particular needs. You may wish to refer to the comparison chart as you work your way through the data storage lessons.
Temporary storage is a simple method of storing and retrieving information in WebKeystone. The information is written to RAM (memory); it is not saved to disk. It is stored in dictionary form and is automatically deleted after 15 minutes. It is retrievable and, once retrieved, may be manipulated using the full power of WebKeystone. Here is an example which uses temporary storage for login passcodes:
<FORM ACTION="/wkstone/webkeystone.py" METHOD=POST> <INPUT TYPE=HIDDEN NAME="UserID" VALUE="biz_webkeystone"> <INPUT TYPE=HIDDEN NAME="Profile" VALUE="lessons/set3/lesson3-1Register.prof"> <CENTER> <TABLE BORDER="1" CELLPADDING="5" CELLSPACING="0" WIDTH="90%" BGCOLOR="#FFFFCC" COLS="2"> <TR> <TD> <H3>Enter registration information and click "Submit" to receive your passcode:</H3> Name:<INPUT TYPE=TEXT NAME="Name.req" SIZE=25><BR> Email:<INPUT TYPE=TEXT NAME="Email.req.vEmail" SIZE=25><BR> <INPUT TYPE=SUBMIT VALUE="Submit"><INPUT TYPE=RESET VALUE="Clear form"> </TD> </TR> </TABLE> </CENTER> </FORM> |
# Profile for Lesson 3-1 Registration
# Check for missing required fields
IF MissingReq
RETURN 'lessons/set3/lesson3-1RegisterMissing.html'
ELSE
# Create a unique "Passcode"
NEWID Passcode
# Save the Passcode in temporary storage
TF_WRITE Passcode
# Send the Passcode to the email address
MAIL
TO Email
FROM 'lesson3-1@webkeystone.com'
SUBJECT 'Your Passcode'
BODY 'lessons/set3/lesson3-1Mail.txt'
RETURN 'lessons/set3/lesson3-1RegisterReturn.html'
|
<HTML> <HEAD> <TITLE>Lesson 3-1 Register Endfile</TITLE> </HEAD> <BODY BGCOLOR="#FFFFFF" LINK="#CC0000" VLINK=#000000 ALINK="#999999"> <H2>Your registration has been accepted</H2> Please check your email to obtain your confidential Passcode. Copy your <BR>Passcode from the email message and then come back to this form and paste <BR>it into the slot. Then click "Login" to complete the login. <FORM ACTION="/wkstone/webkeystone.py" METHOD=POST> <INPUT TYPE=HIDDEN NAME="UserID" VALUE="biz_webkeystone"> <INPUT TYPE=HIDDEN NAME="Profile" VALUE="lessons/set3/lesson3-1Login.prof"> <B>Passcode:</B><INPUT TYPE=TEXT NAME="Passcode.req"><BR> <P> <INPUT TYPE=SUBMIT VALUE="Login"> </FORM> </BODY> </HTML> |
<HTML <HEAD> <TITLE>Lesson 3-1 Register Missing Endfile</TITLE> </HEAD> <BODY BGCOLOR="#FFFFFF" LINK="#CC0000" VLINK=#000000 ALINK="#999999"> <H2>Sorry, you must enter your name and email address.</H2> <H3>Please click "Back" on your browser, enter your name and email address, and proceed.</H3> </BODY> </HTML> |
Hello %(Name)s, Here is your confidential Passcode. Your Passcode is: %(Passcode)s Please copy and paste it into the login form in your browser. Thank You! -------------------------- This message comes to you as a result of your input in WebKeystone Lesson 3-1. Thank you for visiting the Lesson! |
IF MissingReq
RETURN 'lessons/set3/lesson3-1LoginMissing.html'
ELSE
# Check to see if Passcode is valid
TF_READ Passcode
result
IF result == 'OK'
RETURN 'lessons/set3/lesson3-1LoginReturn.html'
# Looks as though the Passcode is missing or invalid
ELSE
RETURN 'lessons/set3/lesson3-1LoginMissing.html'
|
<HTML> <HEAD> <TITLE>Lesson 3-1 Login Page</TITLE> </HEAD> <BODY BGCOLOR="#FFFFFF" LINK="#CC0000" VLINK=#000000 ALINK="#999999"> <H2>Lesson 3-1 Login Area</H2> <H3>Congratulations! You have successfully logged in using your newly-generated Passcode.</H3> Your reward is access to our passcode-protected photo gallery. Click on any of the links below to view our images. Click your "Back" button to return from the image to this page. <P> <UL> <LI><A HREF="http://www.webkeystone.com/lessons/set3/images/lesson3-1Image1.jpg">Tana of Sitka, Alaska</A> (62K) <P> <LI><A HREF="http://www.webkeystone.com/lessons/set3/images/lesson3-1Image2.jpg">Aircraft Carrier</A> (70K) <P> <LI><A HREF="http://www.webkeystone.com/lessons/set3/images/lesson3-1Image3.jpg">Pride of Baltimore II</A> (63K) <P> <LI><A HREF="http://www.webkeystone.com/lessons/set3/images/lesson3-1Image4.gif">Sunrise in Port Townsend</A> (1.5K) </UL> <P> Please note that your Passcode will expire 15 minutes from the time you registered. If you wait 16 minutes and try to login again in using the same Passcode, you will get an error message. <P> <HR> <CENTER>Click your "Back" button twice to return to Lesson 3-1.</CENTER> <HR> </BODY> </HTML> |
<HTML> <HEAD> <TITLE>Lesson 3-1 Login Missing Endfile</TITLE> </HEAD> <BODY BGCOLOR="#FFFFFF" LINK="#CC0000" VLINK=#000000 ALINK="#999999"> <H2>Sorry, your Passcode is invalid</H2> <H3>Please click your "Back" button to enter the correct Passcode. Note that Passcodes expire 15 minutes after you register. You may register again and get a new Passcode if you like. </BODY> </HTML> |
Temporary storage is created and accessed via commands in your Profile:
Here is a sample portion of a Profile which creates a temporary file, using the NEWID and TF_WRITE commands:
# Create a unique "Passcode"
NEWID Passcode
# Save the Passcode in a temporary file
TF_WRITE Passcode
# Send the Passcode to the email address
# ("Passcode" gets substituted into the .mail file)
MAIL
TO Email
FROM 'lesson3-1@webkeystone.com'
SUBJECT 'Your Passcode'
BODY 'lesson3-1Passcode.mail'
|
For another illustration of temporary storage, visit Example 2, which uses temporary storage in its second Profile to store Voter IDs (login passwords) which expire after 15 minutes.
| Previous Lesson | Next Lesson | Table of Contents | Language Reference Manual |
Updated 10-August-99
|
|
|
|
|
| WebKeystone is a product of Townsend Software, Inc. ©1998 - 2001 Townsend Software, Inc. All rights reserved. |