CGI::Application - PowerPoint PPT Presentation

About This Presentation
Title:

CGI::Application

Description:

CGI::Application. Raleigh.PM :: February 21st, 2005. Jason Purdy. jason_at_journalistic.com ... CGI.pm scripts. Separation of code & design. MVC framework ... – PowerPoint PPT presentation

Number of Views:58
Avg rating:3.0/5.0
Slides: 18
Provided by: pur91
Category:
Tags: cgi | application | com | pm

less

Transcript and Presenter's Notes

Title: CGI::Application


1
CGIApplication
  • Raleigh.PM February 21st, 2005
  • Jason Purdy
  • jason_at_journalistic.com

2
WebDev Evolution
  • CGI.pm scripts
  • Separation of code design
  • MVC framework

3
CGIApplication
  • FSA or Dispatch Table

4
CGIApp Benefits
  • Great framework
  • Strong community
  • Much much more

5
Whats it good for?
  • Multi-step applications

6
Development Approach
  1. Mock-up Screens
  2. Write Instance Script
  3. Write CGIApp Frame PM
  4. Code / Test / Debug
  5. Roll Out

7
Typical Scenario 3-Step Application
Show receipt
Enter user data
Enter credit card data
8
Mock-up Screens (write Template files)
lthtmlgt First Name ltinput typetext
namefname /gt Last Name ltinput typetext
namelname /gt ltinput typehidden namerm
valuecc_data /gt lt/htmlgt
user_data.TMPL
lthtmlgt CC ltinput typetext namecc_num
/gt Exp. Date (MMYY) ltinput typetext
namecc_exp /gt ltinput typehidden
namefname valuelt!-- TMPL_VAR NAMEfname
ESCAPEHTML --gt /gt ltinput typehidden
namerm valuereceipt /gt lt/htmlgt
cc_data.TMPL
lthtmlgt Thanks for your Order! Ref Num lt!--
TMPL_VAR NAMEref_num --gt lt/htmlgt
receipt.TMPL
9
Write Your Instance Script
https//www.example.com/payme.cgi
!/usr/bin/perl wT this is payme.cgi us
e strictuse MyModule my app
MyModule-gtnew() app-gtrun()
10
Write cgiapp Frame PM
package MyModule use base CGIApplication sub
setup my ( self ) self
shift self-gtrun_modes( user_data,
red cc_data, yellow receipt
green ) self-gtmode_param( rm
) self-gtstart_mode( user_data
) self-gttmpl_path( /path/to/your/template/file
s ) self-gterror_mode( error )
Commented out, but good practice 1
11
Flesh Out Individual Runmodes
package MyModule sub setup .. sub
user_data my ( self, template ) self
shift template self-gtload_tmpl(
user_data.TMPL ) return template-gtoutput()
1
12
Flesh Out Individual Runmodes
package MyModule sub setup .. sub
user_data .. sub cc_data my ( self,
query, template ) self shift query
self-gtquery() template self-gtload_tmpl(
cc_data.TMPL, associate gt
query, ) return template-gtoutput() 1
13
Flesh Out Individual Runmodes
package MyModule sub setup .. sub
user_data .. sub cc_data .. sub receipt
my ( self, query, ref_num, template
) self shift query self-gtquery()
Imaginary bill_card() method takes the CGI query
object and gets the data out of it and returns
a ref_num ref_num bill_card( query
) template self-gtload_tmpl( receipt.TMPL
) template-gtparam( ref_num gt ref_num
) return template-gtoutput() 1
14
Gravy
  • Add Plugin Code ValidateRM and Session
  • Easy to port to mod_perl
  • Anonymous handler in httpd.conf OR handler()
    method in your .PM class
  • Keep in mind
  • Code changes will need apache restarts
  • Template Caching Directives

15
I ? ValidateRM
  • Very easy and powerful way to verify user data
    input (this may lead to another Raleigh.PM talk)

use CGIApplicationPluginValidateRM sub
user_data my ( self, errs, template
) self shift errs shift
... template-gtparam( errs ) if errs sub
cc_data my ( self ) self shift my (
results, err_page ) self-gtcheck_rm( user_d
ata, _dfv_profile ) return err_page if
err_page 1
16
I ? ValidateRM
  • Very easy and powerful way to verify user data
    input (this may lead to another Raleigh.PM talk)

use CGIApplicationPluginValidateRM sub
user_data .. sub cc_data .. sub
_dfv_profile return required gt qw(
fname lname ) 1
17
Reference
  • CGIApp Wiki http//cgi-app.org
  • Mailing Lists
  • CGIApp
  • cgiapp-subscribe_at_lists.erlbaum.net?SubjectSubscri
    be
  • HTMLTMPL
  • http//lists.sourceforge.net/lists/listinfo/htmltm
    pl-support
  • DFV
  • http//lists.sourceforge.net/lists/listinfo/cascad
    e-dataform
Write a Comment
User Comments (0)
About PowerShow.com