$PBExportHeader$pwedemo.sra $PBExportComments$PB Web Easy Demo Application Object forward global type pwedemo from application end type global transaction sqlca global dynamicdescriptionarea sqlda global dynamicstagingarea sqlsa global error error global message message end forward global variables n_cst_cgienv cgienv n_cst_log log n_cst_httpheader httpheader n_ds_session session n_cst_stdin stdin n_cst_stdout stdout n_cst_db db //string docroot = "/pb9webeasy/" string webpath = "/pb9webeasy/" string jsresourcepath = "/pb9webeasy/" end variables global type pwedemo from application string appname = "pwedemo" end type global pwedemo pwedemo type prototypes end prototypes on pwedemo.create appname="pwedemo" message=create message sqlca=create transaction sqlda=create dynamicdescriptionarea sqlsa=create dynamicstagingarea error=create error end on on pwedemo.destroy destroy(sqlca) destroy(sqlda) destroy(sqlsa) destroy(error) destroy(message) end on event open;string ls_logmessage boolean lb_needsession = TRUE ls_logmessage = "Creating globals "+String (cpu()) stdin = create n_cst_stdin stdout = create n_cst_stdout cgienv = create n_cst_cgienv HTTPHeader = create n_cst_httpheader session = create n_ds_session log = create n_cst_log db = create n_cst_db // Test for MS IIS HTTPHeader.ib_isiis=( ProfileString (cgienv.of_getinifilename( ),"config","servertype","")="IIS") log.of_addmessage ( 1, ls_logmessage ) powerobject lnv_class string ls_return string ls_application string ls_class string ls_function string ls_sessionid // Connect log.of_addmessage ( 1, "Connecting " + String (cpu()) ) db.of_connect (This.Appname+'db') log.of_addmessage ( 1, "Performing action "+ String (cpu()) ) // Perform app logic If cgienv.of_getpathinfo( ls_application, ls_class, ls_function ) = 1 Then If lb_needsession Then // Any Session ID submitted? If cgienv.of_getcookievalue ( session.SID_NAME, ls_sessionid ) = 1 Then // Load session If session.of_load ( ls_sessionid ) = 1 Then // Session ID was sent Else // Fatal Error, Session not found! End If Else // No Session then create one ls_sessionid = session.of_new () End If End If Choose Case ls_class Case "cgienv" ; ls_return = cgienv.of_invokemethod ( ls_function ) Case "session" ; ls_return = session.of_invokemethod ( ls_function ) Case Else Try lnv_class = Create Using ls_class; Catch (runtimeerror er) SignalError ( 1 , "Can not create instance of class '"+ ls_class + "' " ) End Try ls_Return = lnv_class.Dynamic of_invokemethod ( ls_function ) End Choose If Len ( ls_return ) > 0 Then HTTPHeader.of_addheader( "Pragma" , "no-cache") HTTPHeader.of_addheader( "Cache-Control","no-cache, must-revalidate, post-check=0, pre-check=0") HTTPHeader.of_addheader( "Expires" , "-1") stdout.of_Write (HTTPHeader.of_getHTTPHeader()) stdout.of_Write (ls_return) Else // Check if redirected else do nothing... if HTTPHeader.of_isredirected( ) then & stdout.of_Write (HTTPHeader.of_getHTTPHeader()) //end if End if Else // No valid Path stdout.of_Write (HTTPHeader.of_getHTTPHeader()); stdout.of_Write ( "<BR>Could not translate PATH_INFO") End If session.of_save () log.of_addmessage ( 1, "Disconnecting "+String (cpu()) ) db.of_disconnect () log.of_addmessage ( 1, "Finishing "+String (cpu())) // Display Debug Info at end of HTML document If log.il_loglevel = 1 Then stdout.of_Write (log.of_getlog ( 1 )) //stdout.of_Write (log.of_getlog ( 9 )) Destroy stdout Destroy stdin Destroy cgienv Destroy httpheader Destroy session Destroy log HALT CLOSE end event event systemerror;string ls_message="Runtime Error <br />~r~n" If IsValid ( stdout ) then If IsValid ( Error ) then If IsNull ( Error.Number ) then ; else ; & ls_message += "Error Number: "+ String (Error.Number)+ "<br />~r~n" End if /* If Len ( Error.WindowMenu ) > 0 then & ls_message += "<BR>Window/Menu: "+ Error.WindowMenu+ "~r~n" */ If Len ( Error.Object ) > 0 then & ls_message += "Object: "+ Error.Object+ "<br />~r~n" If Len ( Error.Objectevent ) > 0 then & ls_message += "Event/Function: "+ Error.Objectevent+ "<br />~r~n" If Error.Line > 0 then & ls_message += "Line Number: "+ String ( Error.Line ) + "<br />~r~n" If Len ( Error.Text ) > 0 then & ls_message += Error.Text + "<br />~r~n" End if stdout.of_Write ("Content-Type:text/html;charset=iso-8859-1~r~n~r~n"); stdout.of_Write ( ls_message ) // Display Debug Info at end of HTML document if log.il_loglevel = 1 then stdout.of_Write (log.of_getlog ( 1 )) End if HALT CLOSE end event
- Sources
- pb9webeasy
- PBL
- pwedemo.sra
File: pwedemo.sra
Size: 4879
Date: Sat, 08 Dec 2007 15:38:24 +0100
Size: 4879
Date: Sat, 08 Dec 2007 15:38:24 +0100
- application pwedemo(sra)