On Tue, 27 Apr 2004, Sascha Ebach wrote: > Kirk Haines: I really like the way you described the scaling process. > That seems like a viable possibility I must investigate. I have just > started reading about IOWA and have yet to really check it out. I only > know roughly what it is, but not what it can do for me. Very > interesting. I am _woefully_ behind on getting a release out the door because I want to have some documentation going out with it, and I just haven't found the extra couple hours a day to finish writing it. In a nutshell, Iowa represents content or pieces of content as objects. It provides a seperation of content from code and an easy to use templating system. The content is almost completely plain HTML, with just a bit of special markup via specific tags. The @ character indicates that what follows is a method to execute. The @foo is replaced by the to_s'd result of executing the method. I'll just draw you a quick example: A complete Iowa application will have, at a minimum, 4 files, though I have developed a framework within Iowa to let one use it to create simple 1-page dynamic content or to tie pieces of the application (specific objects) to certain URLs. Using those capabilities adds a few more files. So, simple example: example.rb: ----- #!/usr/local/bin/ruby require 'iowa' require 'iowa/dbpool' #my database pool class MySession < Iowa::Session attr_reader :foo, :bar #you can use these to deliver per/session #data for components to use def initialize(*args) ##### #// Setup useful data sets for the components to use here. ##### super end end class MyApplication < Iowa::Application attr_accessor :dbpool #per application items, such as the database pool def initialize(*args) ##### #// Initialize the application wide db connection pool. ### @dbpool = Iowa::DbPool.new('Mysql','localhost','foo','bar','whatever',2) super end end Iowa.startDaemon('example.cnf') Iowa.run ----- example.cnf ----- socket: hostname: localhost port: 15013 logging: basedir: /usr/local/htdocs/enigo.com/log minlevel: 0 maxsize: 10000000 maxage: 86400 ----- The config file is in YAML format, and is pretty self explanatory, I think. Iowa supports communication with the application process via either TCP socket or Unix domain socket. The example.rb stub gets executed to start the Iowa application process. There always has to be a Main.html. If using the ability to map URLs to objects, Main.html (and the code file for it, Main.iwa) will be two small little files that together provide the dispatcher to pass the action on to the right object. If using the simpler model, then the Main object is where your app must start interacting with the world. Code and content can be included in seperate sections of th same file, or in different files. Main.html ----- <html> <head><title>Silly Example of Iowa App</title></head> <body> <p>This is a silly example. The time is @current_time.</p> <p>Count to ten:</p> <p><repeat oid="numberList">@number </repeat></p> <p>Count to ten vertically:</p> <ul oid="numberList"> <li>@number</li> </ul> <if oid="isMonday?"> <p>It is Monday!!!!</p> </if> <p>The current sum is @sum.</p> <form oid="addNumber"> Enter a number: <input type="text" oid="newnumber"> <input type="submit" value="Add!" oid="addNumber"> </form> </body> </html> ----- Main.iwa ----- <% class Main < Iowa::Component attr_accessor :number, :sum, :newnumber def awake @sum = 0 end def current_time Time.now.to_s end def numbers [1,2,3,4,5,6,7,8,9,10] end def isMonday? Time.now.strftime('%A') == 'Monday' end def addNumber @sum += @newnumber.to_i end end %> <? numberList { item = number list = numbers } ?> ----- That's it. You just write your content directly, making use of The @ notation to invoke methods, using special tags (like <repeat> and <if>), or adding the 'oid=' attribute to another tag to indicate to Iowa that this tag does someting dynamic and to Iowa needs to handle it. And you write your code in regular Ruby. The <% %> and <? ?> Notation is to seperate code from bindings, since those still currently must reside in the same file (though I will probably make it possible to seperate them into their own files soon and thus completely do away with <% %> if wanted). Bindings can be used for a lot of different things. In this example, it creates a list that the <repeat> and the <ul> can iterate over, getting its values from numbers() and putting them, in turn, into @number. I use it for a LOT of production web work ranging from just a few simple dyanmic pages to an application with 10k lines of HTML and 7k lines of code. It makes the work SO much easier because it provides the tools that I need to do everything that I want, and it otherwise stays out of my way. I need to save this post. I can use it in the documentation, I think. Thanks. If you have any questions, don't hesitate to ask. Kirk Haines