Rails vs Web2Py From ”Ruby On Rails” to ”Web to Python”     http://jon.is.emotionull.com
Controllers     class MyTestController < ApplicationController     def index         render_text “Hello World”     end end    def index():      return "Hello World"    
Params    class MyTestController < ApplicationController     def index         render_text “Hello ”+params[:who]     end end    def index():      return "Hello %s" % request.vars.who def index():      return "Hello %s" % request.args[0]    
Dispatching      http://hostname/MyTest/index class MyTestController < ApplicationController     def index         render_text “Hello World”     end end     http://hostname/myapp/mycontroller/index calls def index():      return "Hello %s" % request.vars.who    
Routing  routes.rb    routes.py (reversed routing, with or without  regex, IP filtering)    
Views    <table>  <% @recipes.each do |recipe| %>   <tr>    <td><%= recipe.name %></td>   </tr>  <% end %> </table>    <table>  {{for recipe in recipes:}}>   <tr>    <td>{{=recipe.name}}</td>   </tr>  {{pass}}     </table>
Passing vars in views    class MyTestController < ApplicationController     def index         @message=“Hello World”     end end    def index():      return dict(message=”Hello World”)    
Layouts    <title>Layout Example</title>   <body>     <%= yield %>   </body> </html>    <title>Layout Example</title>   <body>     {{include}}   </body> </html> and in view:     {{extend ‘layout.html’}} body
Forms    <%= form_tag :action => "update" dp %>  Name: <%= text_field "item", "name" %><br />  Value: <%= text_field "item", "value" %><br />  <%= submit_tag %> <%= end %>    def contact():     form = SQLFORM(Article)     if form.accepts(request.vars):         redirect('thanks')     return dict(form=form)    
Validation    ActiveForm::Definition::create :article do |f|  f.section :details do |s|  s.text_element :email,:class => 'required' do |e|     e.validates_as_email :msg => 'not email'  end end    db.define_table(‘Article’,SQLField(‘email’)) db.Article.email.requires=IS_EMAIL()    
Migrations    class Article < ActiveRecord::Migration   def self.up       create_table :articles do |t|         t.column :name, :string         t.column :description, :text       end   end end    Article=db.define_table(‘Article’,            SQLField(‘email’,’string’),            SQLField(‘description’,’text’)    
Queries    Article.find(:first,:conditions => [    "id > :id AND name = :name",         {:id => 3,      :name => "test" }])    db(Article.id>3 and Article.name==’test’).select()    
Gems / Plugins  Lots of them   Free Appliaces (plugin system still under  planning)    
Installation  Must install ruby, Rails, gems, databases   Just a zip (cross­platform)    
Web Administration  Nope    Killer­full fledged administration (even  dedicated for apps)    
Upload files  Plugins (paperclip)  Built in (specify as an 'upload' field    
Users/Roles  Plugins    Built in (trivial to override)    
Application Distribution   'Frozen' Applications     Share the application directory ByteCode compilation    
Ticketing system/VC/ Unit testing  External    Built­in (you can even make patches via web  interface)    
Google App Engine  via JRuby (with LOTS of changes and hacks)    Natively (only framework that runs  UNMODIFIED on GAE)    
Caching  MemCache  For any function cache: in RAM, disk,  memcache or combinations    
Translations  Natively (but still hard to use)  You can add/edit translations via web interface    
Routing  routes.rb  routes.py (reversed routing, with or without  regex, IP filtering)    
Support  Many books, very big community and tutorials    Two 'manual' books, smaller but dedicated  community    
  Thank for watching! Questions? http://jon.is.emotionull.com jon@emotionull.com    

Rails vs Web2py

  • 1.
  • 2.
    Controllers     class MyTestController < ApplicationController     def index         render_text “Hello World”     end end    def index():      return "Hello World"    
  • 3.
    Params    class MyTestController < ApplicationController     def index         render_text “Hello ”+params[:who]     end end    def index():      return "Hello %s" % request.vars.who def index():      return "Hello %s" % request.args[0]    
  • 4.
    Dispatching      http://hostname/MyTest/index class MyTestController < ApplicationController     def index         render_text “Hello World”     end end     http://hostname/myapp/mycontroller/index calls def index():      return "Hello %s" % request.vars.who    
  • 5.
    Routing  routes.rb    routes.py (reversed routing, with or without  regex, IP filtering)    
  • 6.
    Views    <table>  <% @recipes.each do |recipe| %>   <tr>    <td><%= recipe.name %></td>   </tr>  <% end %> </table>    <table>  {{for recipe in recipes:}}>   <tr>    <td>{{=recipe.name}}</td>   </tr>  {{pass}}     </table>
  • 7.
    Passing vars in views    class MyTestController < ApplicationController     def index         @message=“Hello World”     end end    def index():      return dict(message=”Hello World”)    
  • 8.
    Layouts    <title>Layout Example</title>   <body>     <%= yield %>   </body> </html>    <title>Layout Example</title>   <body>     {{include}}   </body> </html> and in view:     {{extend ‘layout.html’}} body
  • 9.
    Forms    <%= form_tag :action => "update" dp %>  Name: <%= text_field "item", "name" %><br />  Value: <%= text_field "item", "value" %><br />  <%= submit_tag %> <%= end %>    def contact():     form = SQLFORM(Article)     if form.accepts(request.vars):         redirect('thanks')     return dict(form=form)    
  • 10.
    Validation    ActiveForm::Definition::create :article do |f|  f.section :details do |s|  s.text_element :email,:class => 'required' do |e|     e.validates_as_email :msg => 'not email'  end end    db.define_table(‘Article’,SQLField(‘email’)) db.Article.email.requires=IS_EMAIL()    
  • 11.
    Migrations    class Article < ActiveRecord::Migration   def self.up       create_table :articles do |t|         t.column :name, :string         t.column :description, :text       end   end end    Article=db.define_table(‘Article’,            SQLField(‘email’,’string’),            SQLField(‘description’,’text’)    
  • 12.
    Queries    Article.find(:first,:conditions => [    "id > :id AND name = :name",         {:id => 3,      :name => "test" }])    db(Article.id>3 and Article.name==’test’).select()    
  • 13.
    Gems / Plugins  Lots of them   Free Appliaces (plugin system still under  planning)    
  • 14.
    Installation  Must install ruby, Rails, gems, databases   Just a zip (cross­platform)    
  • 15.
    Web Administration  Nope    Killer­full fledged administration (even  dedicated for apps)    
  • 16.
    Upload files  Plugins (paperclip)  Built in (specify as an 'upload' field    
  • 17.
    Users/Roles  Plugins    Built in (trivial to override)    
  • 18.
    Application Distribution   'Frozen' Applications     Share the application directory ByteCode compilation    
  • 19.
    Ticketing system/VC/ Unit testing  External    Built­in (you can even make patches via web  interface)    
  • 20.
    Google App Engine  via JRuby (with LOTS of changes and hacks)    Natively (only framework that runs  UNMODIFIED on GAE)    
  • 21.
    Caching  MemCache  For any function cache: in RAM, disk,  memcache or combinations    
  • 22.
    Translations  Natively (but still hard to use)  You can add/edit translations via web interface    
  • 23.
    Routing  routes.rb  routes.py (reversed routing, with or without  regex, IP filtering)    
  • 24.
    Support  Many books, very big community and tutorials    Two 'manual' books, smaller but dedicated  community    
  • 25.
      Thank for watching! Questions? http://jon.is.emotionull.com jon@emotionull.com