[{"data":1,"prerenderedAt":161},["ShallowReactive",2],{"\u002Fweb-programming-with-contize":3},{"id":4,"title":5,"body":6,"createdAt":149,"description":150,"draft":151,"extension":152,"image":153,"mastodonThread":153,"meta":154,"navigation":155,"path":156,"seo":157,"stem":158,"tags":159,"updatedAt":149,"__hash__":160},"content\u002FWeb Programming With Contize.md","Web_Programming_With_Contize",{"type":7,"value":8,"toc":141},"minimark",[9,18,23,26,37,40,44,60,64,70,83,91,95,115,119],[10,11,12,17],"p",{},[13,14,16],"a",{"href":15},"\u002Fcontize","Contize"," was developed specifically to abstract away some of the difficulties of creating web-based applications. Unfortunately it significantly altered what I would call ''intuitive'' web programming. Now various state-maintenance techniques can be replaced with more traditional (and straightforward) programming.",[19,20,22],"h2",{"id":21},"the-goal","The Goal",[10,24,25],{},"Eventually we are going to be writing code in a style that is reminiscent of a command-line script. As a very brief example, you might see code like:",[27,28,33],"pre",{"className":29,"code":31,"language":32},[30],"language-text","sub getTwo {\n  my $self = shift;\n  my $num1 = $self->prompt(\"Enter first number\");\n  my $num2 = $self->prompt(\"Enter second number\");\n  $self->disp(\"The sum is $num1 + $num2 = \" . ($num1 + $num2));\n}\n","text",[34,35,31],"code",{"__ignoreMap":36},"",[10,38,39],{},"From the user's view this would be three web pages. A page asking for the first number, a page asking for the second number, and a page displaying their sum. Notice that we send and receive input and output to the user in a much more direct fashion that in standard CGI script style.",[19,41,43],{"id":42},"additional-tools","Additional Tools",[10,45,46,47,49,50,54,55,59],{},"Alone, ",[13,48,16],{"href":15}," significantly changes the approach to web programming. There are, however, some other existing and important tools which we should continue to use. The idea of ",[13,51,53],{"href":52},"\u002Fmodel-view-controller","Model-View-Controller"," is still very applicable, and I will use some of that terminology here. Contize helps us build controllers. For applications which use a database as their back-end, I suggest cpan:Class::DBI or something similar for the Model component. A template system is useful for the View component, and I prefer a subset of the functionality provided by cpan:Embperl. Some of my ideas on this topic are spelled out in ",[13,56,58],{"href":57},"\u002Fthoughts-and-issues-with-web-based-db-programming","Thoughts and issues with web-based DB programming",".",[19,61,63],{"id":62},"getting-started","Getting Started",[10,65,66,67,69],{},"Since ",[13,68,16],{"href":15}," works on objects, we need for our application to be an object. What we will do is set up a wrapper script which takes care of some initialization for us and manages an instance of our object. The wrapper needs to:",[71,72,73,77,80],"ul",{},[74,75,76],"li",{},"Set up the session",[74,78,79],{},"Save\u002FRestore our main application object to the session",[74,81,82],{},"Execute the main entrypoint method of our application object",[10,84,85,86,90],{},"The first thing you need to be able to do is save and restore an object in your session. I've been using cpan:CGI::Session for this, though it has one quirk I haven't figured out how to get around yet. This isn't a new thing for web programming really... but Contize gives us an extra trick. The object we are putting into the session gets suspended practically in the middle of an operation, and upon reentrance its execution is resumed right where it left off. So really we are storing only ",[87,88,89],"em",{},"one"," object (the application), and all the other pieces should be instance variables of that object. Do what you want though.",[19,92,94],{"id":93},"going-on-from-here","Going On From Here",[10,96,97,98,102,103,105,106,108,109,111,112,114],{},"Well... truth be told I got tired of describing what to do and decided to do what to do. I've packaged up this wrapper script, and will continue to make improvements upon said script, under the name of ",[13,99,101],{"href":100},"\u002Fcontinuity","Continuity",". The above information is still quite appropriate if you are writing your own wrapper to utilize ",[13,104,16],{"href":15}," or similar without ",[13,107,101],{"href":100},", or perhaps if you are trying to integrate ",[13,110,16],{"href":15}," into a different, yet existing, framework. The information above is not nearly complete, however. So if you want to do one of these things I suggest you look at the very simple internals of ",[13,113,101],{"href":100}," and\u002For email me.",[19,116,118],{"id":117},"see-also","See Also",[71,120,121,129,134],{},[74,122,123,128],{},[13,124,125],{"href":125,"rel":126},"http:\u002F\u002Fcsoki.ki.iif.hu\u002F~vitezg\u002Fimpostor\u002F",[127],"nofollow"," - A similar framework for Python. They use an Apache module though... cheating I'd say :)",[74,130,131,133],{},[13,132,16],{"href":15}," - The Perl module on which this is based",[74,135,136,140],{},[13,137,139],{"href":138},"\u002Fcontinuation-based-web-programming","Continuation-based Web Programming"," - The concept on which this is based",{"title":36,"searchDepth":142,"depth":142,"links":143},2,[144,145,146,147,148],{"id":21,"depth":142,"text":22},{"id":42,"depth":142,"text":43},{"id":62,"depth":142,"text":63},{"id":93,"depth":142,"text":94},{"id":117,"depth":142,"text":118},"2004-10-17T19:01-04:00","Contize was developed specifically to abstract away some of the difficulties of creating web-based applications. Unfortunately it significantly altered what I would call ''intuitive'' web programming. Now various state-maintenance techniques can be replaced with more traditional (and straightforward) programming.",false,"md",null,{},true,"\u002Fweb-programming-with-contize",{"title":5,"description":150},"Web Programming With Contize",[],"vuhl0lKWrOdnmjWkWMpMhwT_nlJojbBqb2jYifgdrIg",1778988315481]