asp website templates

Reviews
Shared by: Mark Hardigan
Stats
views:
86
rating:
not rated
reviews:
0
posted:
1/22/2009
language:
pages:
0
Advanced Apache::ASP by Joshua Chamas Session ID 1257 O'Reilly Open Source Convention July 23 - 27, 2001 Sheraton Harbor Island San Diego, Calfornia Problem Domain We are building web sites but what is a web site? l Presenting rich media & documents Building thin web client & heavy web server software l Its not a choice, we are doing both! Graphics Design A graphic design approach to web sites often starts with WYSISIG tools. ( What you see is what you get! ) Features often include: l l l Drag & Drop style creation. Easily accessible rich media objects. Integration with other graphics design tools. Examples of such tools include Dreamweaver, FrontPage, and Adobe GoLive. Software Engineering Start with a software engineering approach, and you'll likely end up starting with requirements, functional specs, objects interfaces & hierarchies. Tools of the trade often include: l l l l l The programming language, Perl The text editors, like Emacs, Vim, & UltraEdit Application frameworks, like Apache::ASP Other useful software packages, from CPAN Process & data modeling products, e.g. Visio Problems with Graphics Design Graphics design takes an immediate approach to creating a web site. Problems with this include: l l l l HTML code often not cross browser compatible. HTML code produced is hard to debug. Components are not reused. Components are not reusable. The web site will quickly become a mess, with hundreds and thousands of pieces in disarray. But the first release was done in a week! Problems with Software Engineering Normal engineering practices do not lend themselves well to rapid development of finished products. The waterfall method seen right is still taught in schools for standard software engineering practices. Problems with Software Engineering "Waterfall" model: l l l Is linear, fixed. Assumes creators in early stages predict the future. Fixing mistakes made in earlier stages is exponentially costly. The effect is the customer gets little say on real improvements. Wait until v2.0 of the product, next year. Web Application Fusion Why not fuse the rapid development of web design with the process, architecture, and componentizaion of software engineering? Apache::ASP directly supports this hybrid model. For the purposes of this discussion, you are the Project Manager where any web application we might build is your project. The following development model is inspired in part by the notion of incremental development suggested in the book The Mythical Man-Month, citing Harlan Mills as a source for this notion. Diamond Development 1. Develop a sequence of mini web site launches that lead to the finished product. 2. Fuse requirements & specifications, to requirements. 3. Fuse design to implementation, and do what's appropriate for phase of project. 4. Iterated over sequence until done. Diamond Development - Who Chart Customer Calls Customer calls and says something like: "We want to build a portal like Yahoo!". "OK", you say, "but you will have to be specific with what you have in mind for implementation." implementation "Oh.", silence. "How about for starters: our corporate logo, some company contact info, and some industry related links, and partner information?" "OK", you say, "just give me a couple weeks and I'll have something for you." Requirements, Round 1 Before you forget, quickly jot down the customer's requirements for their web site, and if necessary gather the relevant initial content from the client: l l l l corporate logo company contact info industry related links partner information Don't get bogged down in details that can be easily solved, but don't have too yet: l l l separation of logic, formatting, & content data collection for click stream analysis scaling to 1,000,000 users / day Early Requirements Mistake Do not let your customer talk to your developers! Your job as the Project Manager is to: l l l keep the developers on some sort of schedule make sure they have a nice undisturbed space to work in and get everything else out of their way. This includes the customer. "The manager's function is not to make people work, it is to make it possible for people to work." (Mythical Man-Month, p.276, citing Peopleware: Productive Projects & Teams) Implementation Strategy, Round 1 In this stage, you want to build a functional prototype of what was asked for in the shortest amount of time. Its important to spend the least resources on the project now, as the customer will likely add to or change the requirements once they see the first iteration. Implementation, Graphics Design Your graphics designer or HTML developer is the perfect choice for this implementation iteration. Surprise the customer with a beautiful layout, but don't spend engineering time it. Your fast graphics person might use a WYSIWIG tool to crank out the site in a day! But you don't want to see the HTML it produces... Show Customer, New Requirements l l No formal QA yet, too simple. Customer pleased, wants more. Customer now wants new NEWS page: l l like to update news articles live with online tool prefers news as XML data feed, has editing tool Also would like date stamp on pages to make it look fresh, like July 23, 2001. Future needs might include SQL database: l l click stream data for reporting analysis sales registration form data from visitors Web Site Implementation Round 2 Transition from static site to dynamic site requires embedded web application framework like Apache::ASP. l l l Facilitates incremental development model. Add code in <% %> as necessary. Decompose HTML into XMLSubs tags & templates. Today is <%= time2str ("%B %e, %Y", time) %> Today is July 23, 2001 Apache::ASP allows for quick reuse of original HTML produced by WYSIWIG tool. Web Site Platform, Open Source Apache::ASP runs well on Unix platforms and requires the following open source software: l l l Apache Web Server Perl scripting language mod_perl Apache module Open source SQL database backend no problem for future possible requirements: l l MySQL PostgreSQL Web Implementation Developers Need up to 2 people now: l Web Application Framework Lead Engineer Good experience with perl gets OO paradigm, modularity, code reuse understanding of complex data structures works well with packages believes in "use strict" ¡ ¡ ¡ ¡ ¡ l Web Template Developer Good experience with HTML. Can learn perl: loops, conditionals, variables Can work with Lead Engineer! ¡ ¡ ¡ Static Site Decomposition Split the static web site into reusable templates. Candidates for template decomposition are marked in red: Template Decomposition Criteria Motivations for template decomposition include: l l l separation of logic, content, & formatting complexity reduction / readability reusability Templates are similar to methods & subroutines for the latter 2 motivations. Template Decomposition, Not These These HTML components marked earlier probably do not need separate templates: l l l
Natural parts of parent template. No separate use. Low complexity. Template Decomposition, Do These Templatize these regions, for the following reasons: l HTML Complexity & Reusability ¡ ¡ l Perl Code Complexity & Reusability ¡ ¡ Template Decompostion Tools - Includes Methods for includes as subroutines: <% $Response->Include($file, @args) %> Output from script $file goes to browser <% $Server->Execute($file, @args) %> Same as $Response->Include <% my $output = $Response->TrapInclude($file, @args) %> <% $Response->Write($$output) %> $output is a scalar ref to \$html that would normally have gone to $Response->Write() Useful for post processing. @args are accessible as @_ of the template. Template Decompostion Tools - XMLSubs Treat XML tags as perl subroutines, with tag like: Some Text transformed into call to &app::page() like: <% &app::page( { color => "red", width => "600" }, 'Some Text' ); %> The subroutine definition could look like: sub app::page { my($args, $html) = @_; ... } XMLSubs Quick Example Write a replacement for tag: Apache::ASP # httpd.conf PerlSetVar XMLSubsMatch a # package app.pm, maybe in Global directory # print() is alias for $Response->Write(); sub a { my($attr, $html) = @_; print qq($html); } XMLSubs - Why? Template includes take care of heavy formatting, but then calling scripts look like:
<% $Response->Include("this.inc"); %> <% $Response->Include("that.inc"); %>
If reduced with XMLSubs tags:
The latter is better for content creators & HTML developers. Content, Logic, Formatting Thus without pure XML/XSLT, we can still have a mechanism for content separation from logic & formatting. Content -> ASP Scripts Logic -> XMLSubs Formatting -> Templates Also for web template developers, XMLSubs can be hooks into complex code that they are unaware of. No perl OO, no heavy scripting. XMLSubs Setup We will create a tag library in the namespace so as to not conflict with regular HTML tags. # httpd.conf PerlSetVar XMLSubsMatch app:\w+ # app.pm package app; sub page {} sub navbar {} sub bigbox {} sub partner {} # # # # PAGE CONTENT BOX CONTENT PARTNER Now to componentize the WYSIWIG HTML! WYSIWIG HTML Sample ...
Include('app_page.inc', $args, $html); } sub app::navbar { print "NAVBAR STUB" } app_page.inc <% my($args, $body) = @_; %> Global Inc. Portal: <%= $args->{title} %>

Global Inc. Portal Site
<%= time2str ("%B %e, %Y", time) %>
 
 
<%= $body || 'BODY STUB' %>
  Global Inc., San Diego CA, 99999
contact@globalinc.com.fake
XMLSub app:page And now for our first engineered web page: index.asp To finish the Home Page we must construct the and fill in the page's contents. XMLSub app:navbar global.asa use File::Basename qw(basename); my %Pages = ('index' => 'Home', 'links' => 'Links', 'partners' => 'Partners' ); sub app::navbar { my($args) = @_; my $size = $args->{size} || 2; my $basename = basename($0); my @links = split(/,/, $args->{links} || 'index,links,partners'); print ""; for my $page (@links) { my $title = uc $Pages{$page}; my $text = ($basename =~ /$page/) ? $title : qq($title); print qq{}; } print "
$text
"; } Home Page Extend and reuse! Welcome to Global Inc. portal site, where you can get Global's latest links, and explore the web with Global's partners, and contact Global.

XMLSub app:bigbox We build a , which we find to be composed of two smaller tags. global.asa sub app::bigbox { my($args, $html) = @_; $main::Response->Include('app_bigbox.inc', $args, $html); } app_bigbox.inc <% my($args, $body) = @_; %> <%= uc($args->{title}) || "NEEDS TITLE" %>
<%= $body %>
global.asa sub app::borderbox { my($args, $html) = @_; $main::Response->Include('app_borderbox.inc', $args, $html); } app_borderbox.inc <% my($args, $body) = $args->{outer} ||= $args->{inner} ||= $args->{width} ||= @_; 'red'; 'white'; '100%'; %>
<%= $body %>
XMLSub app:bigbox is done. partners.html
[ partner links here ]
XMLSub app:partner we aliased to .... Mark up content now, upgrade later. global.asa sub app::partner { my($args, $html) = @_; print qq($html); } partners.html


Final Partner Page QA for Round 2 Now is good time to QA for the 1st time: l l l l 3 pages of functional testing cross browser testing load testing beginning build of regression tests QA Requirements In order for QA to be effective they need separate but identical hardware & software. l l Changes in dev won't affect QA until released Parallel QA to development progress Identical components needed are: l l l l physical hardware ( if possible ) perl installations apache + mod_perl installations Apache::ASP versions, and CPAN modules QA needs to be like development environment. Production needs to exactly reproduce QA env. QA Empowerment QA needs full autonomy from developers. l l stop code release from going to production possibly in charge of publishing processes Needs developer man power too, especially for building QA regression tests. Developers as QA! Autonomy from, but compatible with developers. QA must often rely on developers for risk analysis & technical expertise. QA Scheduling No one idles! Have weekly, bi-weekly development cycles with firm code release dates on regular schedule. Non-regularity promotes errors making it to production. Concurrent development model, QA working on Round 2 code branch checked in last week, while developers work on Round 3 features. QA Regression Testing For testing web sites, functional regression testing done well by scripted web client. Good tools for this: l l l l HTTP::WebTest, regression web testing LWP, HTTP programming LWP::UserAgent LWP::Simple lwp-request SilkTest from Segue Software Inc. New RoboWeb project looks promising. http://sourceforge.net/projects/roboweb ¡ ¡ ¡ Regression testing useful to developers, QA, and post production release verification. Production Publishing After Round 2 QA passes, OKs the publish. Customer not seeing until Round 3 is done, but production practice this period is good. Publishing tools: l Remote copy rsync: ssh secure, compression, changes only ftp: not useful for single box for dev/qa/prod ¡ ¡ l Software Configuration Management (SCM) Production server is another developer workspace cvs: cvs update perforce: p4 sync ¡ ¡ Production Publishing Timing How to rollout to production, with ability to recover... 1. backup current code in production 2. stop Apache httpd 3. publish changes 4. start Apache httpd 5. regression testing If regression tests fail: l l l l stop Apache httpd restore backup start Apache httpd regression testing This entire process can be automated. Production Monitoring Make sure your site stays online: l l l Periodic regression tests Ping specific test cases with LWP scripting Home page SSL page Database read transaction Database write transaction Outsource: Keynote Systems, advanced reporting & expensive NetMechanic affordable for URL monitoring. ¡ ¡ ¡ ¡ ¡ ¡ Monitoring typically provides means to notify person on call in realtime. Production Realtime Error Notification Apache::ASP realtime error notification: # set SMTP host PerlSetVar MailHost your.smtp.server.hostname # set destination email for receipt of full error message # plus debugging data PerlSetVar MailErrorsTo youremail@yourdomain.com # send small alert, suitable for pager to this address # whenever error occurs, 1 per MailAlertPeriod PerlSetVar MailAlertTo youremail@yourdomain.com # Period in minutes during which only one MailAlert # may be sent for errors at the web site PerlSetVar MailAlertPeriod 20 Production Security, Don't Get Hacked No point deploying web site on hostile internet, if don't secure your servers. Firewall Security: l l l ipchains for Linux IP Filter for other platforms Commercial solutions abound, e.g. Checkpoint Host level security: l l l OpenBSD, supposedly very secure base install Bastille Linux to harden distributions Tripwire, IDS for ongoing maintenance Know when you have been hacked! Round 3, Implementation In Round 2, we engineered the web site with good design principles. No new features. No customer feedback needed. Now we implement the XML news features, which Apache::ASP will support well out of the box. Steps: 1. Administrative Login 2. XML News File Upload Tool 3. XML News Rendering Page Adminstrative Login The admin login page functionality can be broken into 3 parts: l l l Admin Login Page Database Connection Process Login Credentials Administrative Login Page Allow for deeper XMLSubs packages... PerlSetVar XMLSubsMatch app:[\w:]+ and then create app:form tag space:
Admin Login Page XMLSubs sub app::form::table { my($args, $html) = @_; my $basename = basename($0); print qq(\n); $args->{title} && print ("\n"); print "$html
". "$args->{title}
\n"; } sub app::form::row { my $args = shift; $args->{name} || die("need name for form row".join(%$args)); $args->{title} && ( $args->{title} .= ':' ); # NULL titles OK $args->{value} = $main::Server->HTMLEncode($args->{value}); print <$args->{title} HTML ; } Admin Login Page Screen Database Connection 1. Connect to database in each Script_OnStart 2. Create $App object, store $Db & misc there global.asa, Script_OnStart use DBI; use vars qw($App); sub Script_OnStart { $main::App = $app::App = $App = bless { Db => DBI->connect('dbi:mysql:hostname=mysql;database=test', 'test', 'test', { RaiseError => 1 }), Form => $Request->Form, }; } { shift->{Form}{username} }; sub username { shift->{Form}{password} }; sub password { shift->{Form}{login} }; sub login sub login_done { $Response->Redirect('admin_login.asp'); } Process Login Credentials Add XMLSubs method to check for login credentials. admin.asp, top global.asa, app:login sub app::login { if($App->login) { my $pass_csr = $App->{Db} ->prepare("select username from passwords ". "where username = ? ". "and password = ?"); $pass_csr->execute($App->username, $App->password); my $valid_user = $pass_csr->fetchrow_arrayref; if($valid_user) { $main::Session->{login} = 1; $App->login_done; } } } Form Fill To have the form redraw itself with the user input on password verification error, just set: PerlSetVar FormFill 1 and have already installed HTML::FillInForm. XML News File Upload Page global.asa, app:upload:table tag sub app::upload::table { my($args, $html) = @_; my $basename = basename($0); print qq(
\n); $args->{title} && print("\n"); print "$html
". "$args->{title}
\n"; } admin_login.asp, file upload
New File Upload Format The agreed format for the news file upload looks like: news.xml
This is news! 2001-07-23 The news article text here. Something very special happened today, and we are going to tell you about it now.
This is news too! 2001-07-22 The other news article text here. Something else news worthy happened.
File Upload Process Add a tag to the admin_login.asp script whereever you want success/error output to be returned for the upload.
=>
File Upload Process Use full XML parser, like XML::Simple to deal better with deep XML structures. Apache::ASP XMLSubs better at rendering flat XML structures. global.asa, app:upload:process tag use XML::Simple; sub app::upload::process { my $Request = $main::Request; if($Request->{FileUpload}{upload_file}) { local $SIG{__DIE__} = 'die'; my $fh = $Request->{FileUpload}{upload_file}{FileHandle}; my $data = join('', <$fh>); my $error; my $ref = eval { &XMLin($data); }; $@ && ($error = "Error in XML: $@"); if($ref && ! $ref->{article}) { $error = "There were no articles found in the upload!"; } if($error) { print "$error"; return; } open(FILE, ">news.xml") || die("no write access to news.xml: $!"); print FILE $data; close FILE; print "News Upload Success!"; } } News Page Don't always decompose code from templates into perl libraries. Motivations for decomposing templates include: l l code reuse template readability for HTML developers Example here to not remove all code possible. news.asp <% if(! -e 'news.xml') { %> No news posted yet. <% } else { my $news = XMLin(); %>
<% for my $article ( @{$news->{article}} ) { %> <% } %>

GLOBAL NEWS

<%= $article->{title} %> <%= $article->{date} %>
<%= $article->{body} %>
<% } %>
News Page Date Stamp The customer also wanted a date stamp on the pages like July 23, 2001. First, we load the Date::Format module in global.asa: global.asa use Date::Format qw(time2str); Then we add some date code below the header: app_page.inc
<%= time2str ("%B %e, %Y", time) %> ALL pages update, since all used the tag. Maintenance, Source Control Big development items done, now in maintenance mode for customer. To make source management nicer, get a code release policy consistent with the tool you are using like CVS or Perforce. Then make sure, you have code split up logically into lots of files. Reduce inter-developer source change collisions. Maintenance, Source Control The prior examples placed a lot of code in global.asa. Leave only in global.asa: l l ASP event handlers "use module" declarations, especially to import module exports into scripts and includes. Thus, global.asa would likely get split up into: l l l l l global.asa Site/App.pm - for the $App object, init as Site::App->new() app.pm - for the app:* tags app/form.pm - for the app:form:* tags app/upload.pm - for the app:upload:* tags Scaling to 1,000,000 Users per Day What is 1,000,000 users per day? 10 clicks per user? Most hits average across 12 hour period ( assume ), so the rate that is needed to be handled is: 1,000,000 users/day x 10 hits/user ---------------------------------- = 231 hits / sec. 12 hours x 3600 seconds/hour OK, let's plan for double capacity, an even 460 hits/sec that we want to handle. Scaling to 1,000,000 Users How fast is application currently? Take home page speed test of index.asp using ab, ApacheBench. ]# ab -c 5 -n 500 http://gate/asp/apps/ginc/index.asp This is ApacheBench, Version 1.3c <$Revision: 1.38 $> apache-1.3 Time taken for tests: 16.751 seconds Requests per second: 29.85 Transfer rate: 63.55 kb/s received I can get 30 hits/sec on a PIII dual 400 with $Session active. A dual 1GHz processor would likely be 2.5 times faster, at 75 hits per sec. So we need a web cluster of 6 machines with dual 1GHz CPUs, and knowing how mod_perl eats up RAM, probably 1G RAM each box too! Web Clustering The clustering is not native to Apache::ASP. Must use front end web load balancers like: l l l l Linux Virtual Server Project Round Robin DNS with short TTL's Alteon Web Systems Products Cisco Local Director ... just to name a few. $Session Clusters with Apache::Session If using $Session, cannot cluster with hot failover or fault tolerance because the Apache::ASP $Session files are on local disk. Work-around is to use Apache::Session to store session files to a central database, like this: global.asa use Apache::Session::MySQL; sub Script_OnStart { # ... init mysql dbh before my $id = $Request->Cookies("SESSION_ID"); tie %hash, 'Apache::Session::MySQL', $id, { Handle => $dbh, LockHandle => $dbh }; if($id ne $hash{_session_id}) { $Response->Cookies("SESSION_ID", $hash{_session_id}); } $Session = \%hash; $Server->RegisterCleanup(sub { untie (%$Session) }); } $Session Clustering, smaller cluster With PerlSetVar NoState 1 set, disabling $Session and $Application, performance goes to 120 hits/sec on my 2x400 PIII Linux server. Likely drop to 100 hits/sec with Apache::Session overhead, but with sessions centralized at database, cluster will likely shrink to 2 web servers with dual 1 GHz CPUs, with 1 dual 1GHz CPU MySQL database serving as the $Session database. Cluster shrinks from 6 to 3 servers. MySQL new single point of failure and potential bottleneck for further scaling. Apache::Session Drawbacks Apache::Session does not support: l l l Session_OnStart and Session_OnEnd ASP events No Session Manager to garbage collect stale sessions Good API for $Application construction. Future work on Apache::ASP will include support for $Session & $Application storage in database, but will be slower than a raw Apache::Session $Session because of support for the above features. THE END

Related docs
asp site templates
Views: 23  |  Downloads: 2
dreamweaver asp templates
Views: 98  |  Downloads: 19
professional website templates
Views: 11  |  Downloads: 2
Website Pros Templates v1.0
Views: 73  |  Downloads: 0
ASP Tutorial
Views: 563  |  Downloads: 80
Computer Notes
Views: 46  |  Downloads: 4
ASP-Dot-Net-20-Step-by-Step
Views: 335  |  Downloads: 43
Vendor Templates
Views: 742  |  Downloads: 28
Custom Templates
Views: 70  |  Downloads: 2
Other docs by Mark Hardigan
Sexual Harassment Policy2
Views: 252  |  Downloads: 4
Sample Agreement to Form Business Entity
Views: 483  |  Downloads: 7
Customer Satisfaction Survey
Views: 919  |  Downloads: 67
Stock Certificate for Common Stocks
Views: 453  |  Downloads: 17
Duke ECE 163 Lab Manual
Views: 1112  |  Downloads: 30
Evolution and Ethics
Views: 478  |  Downloads: 4
MAILING LIST ORGANIZER
Views: 506  |  Downloads: 32
Business selection checklist
Views: 493  |  Downloads: 16
Ingram Micol Inc Ammendments and Bylaws
Views: 121  |  Downloads: 0