[cgiapp] CGI::App Developing Runmodes Structure

John Cianfarani jcianfarani at rogers.com
Sat Apr 3 16:43:45 EDT 2010


Hello All,

 

First post here, I'm beginning to embark on my own web app and from all my
reading it seems C:A will fit the bill quite nicely.  I've read through most
of the examples on the homepage and various other section but I'm still not
full understanding properly how to structure my run modes and what should be
done in them.  I'm hoping the people here can make sure I'm on the right
path from the start.  Using a reasonable approach to MVC.

 

My example project would be accessed via web and a cli (web most important
for now though)  I'll go through my thoughts on the user management piece to
start out with.

Web Site Sections

Login /  User Management /  Site Management / Assets Management

 

Runmodes / Packages

 

Base - Runmode - Separate instance script / MyApp::Base package which
handles login/logout/DB setup/sessions etc

- Login_form - Generates login page

- Login_Process - Validates user and moves them to the BaseDefault runmode.

- BaseDefault- Runmode-  Generates page with default options
(user/site/asset management)

 

User Management - MyApp::UserManager Package / All these use the base
package to determine authentication and dbh handles. / Separate instance
script

- UserDefault - Runmode - Calls "view" sub to generate a page with options
(display/new/edit/delete)

- DisplayUser - Runmode - Would call additional "model" subs to actually do
the data retrieval and then determine which type of "view" and call a sub to
generate that view type?

- NewUser_form - Runmode - Calls a "view" sub to generate a display form

- NewUser_process - Runmode - Calls a "model" sub to check form data if it
constrains to business logic, and sub to update db. 

- EditUser_page1_form - Runmode (similar to newuser_form with additional db
pulls)

- EditUser_page1_process - Runmode (similar to newuser_process) Sends user
to EditUser_page2_form

- EditUser_page2_form - Runmode (similar to newuser_form with additional db
pulls)

- EditUser_page2_process - Runmode (similar to newuser_process)

- DeleteUser - Runmode - Calls "model" subs to delete from db.

 

Is it correct to assume that each function user/site/asset management will
be their own instance script with its own set of runmodes?

In one  faq page it says to stay around the 4-12 runmodes for a project am I
creating too many? How would you deal with multiple pages to edit?

For cli versions of my script would I just create separate instance scripts
with some new variable eg $CLI = YES;?

 

I have more questions but hopefully this is a good start.

 

Thanks

John

 

 

 

 

 

 

 

 



More information about the cgiapp mailing list