SlideShare a Scribd company logo
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
                     

More Related Content

PDF
web2py:Web development like a boss
PDF
You suck at Memory Analysis
PPTX
Django Architecture Introduction
KEY
Jumpstart Django
PPT
PDF
Web Development with Python and Django
PDF
Building a Dynamic Website Using Django
PDF
PECL Picks - Extensions to make your life better
web2py:Web development like a boss
You suck at Memory Analysis
Django Architecture Introduction
Jumpstart Django
Web Development with Python and Django
Building a Dynamic Website Using Django
PECL Picks - Extensions to make your life better

What's hot (20)

PPT
Overview of PHP and MYSQL
PPTX
PHP FUNCTIONS
PPTX
Laravel 5
PPTX
PHP 7 Crash Course - php[world] 2015
PDF
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
PDF
Python & Django TTT
PDF
Building Content Types with Dexterity
PPTX
Php on the Web and Desktop
PPTX
The Django Web Application Framework 2
PPTX
PyGrunn 2017 - Django Performance Unchained - slides
PDF
Django Framework and Application Structure
PDF
Zend Framework 2 Components
PPTX
PHP7 Presentation
PPT
PHP - Introduction to PHP Fundamentals
PDF
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
PDF
Flask - Backend com Python - Semcomp 18
PDF
Last train to php 7
PDF
Design patterns revisited with PHP 5.3
PPTX
PDF
Dexterity in the Wild
Overview of PHP and MYSQL
PHP FUNCTIONS
Laravel 5
PHP 7 Crash Course - php[world] 2015
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Python & Django TTT
Building Content Types with Dexterity
Php on the Web and Desktop
The Django Web Application Framework 2
PyGrunn 2017 - Django Performance Unchained - slides
Django Framework and Application Structure
Zend Framework 2 Components
PHP7 Presentation
PHP - Introduction to PHP Fundamentals
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Flask - Backend com Python - Semcomp 18
Last train to php 7
Design patterns revisited with PHP 5.3
Dexterity in the Wild
Ad

Similar to Rails vs Web2py (20)

PDF
Ruby on Rails : 簡介與入門
ZIP
Rails 3 (beta) Roundup
KEY
Rails Presentation (Anton Dmitriyev)
PDF
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
PDF
Ruby on rails探索
PDF
Rails 3 : Cool New Things
PDF
RubyEnRails2007 - Dr Nic Williams - Keynote
PDF
PDF Ruby on Rails 3 Day BC
PDF
Curso rails
PDF
Pourquoi ruby et rails déchirent
PDF
Rails 4.0
PDF
Connecting the Worlds of Java and Ruby with JRuby
KEY
Rails Routing and URL design
KEY
Supa fast Ruby + Rails
PDF
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
KEY
深入淺出RoR
PDF
Ruby on Rails 3.1: Let's bring the fun back into web programing
PDF
Ruby on Rails : RESTful 和 Ajax
PDF
td_mxc_rubyrails_shin
PDF
td_mxc_rubyrails_shin
Ruby on Rails : 簡介與入門
Rails 3 (beta) Roundup
Rails Presentation (Anton Dmitriyev)
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Ruby on rails探索
Rails 3 : Cool New Things
RubyEnRails2007 - Dr Nic Williams - Keynote
PDF Ruby on Rails 3 Day BC
Curso rails
Pourquoi ruby et rails déchirent
Rails 4.0
Connecting the Worlds of Java and Ruby with JRuby
Rails Routing and URL design
Supa fast Ruby + Rails
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
深入淺出RoR
Ruby on Rails 3.1: Let's bring the fun back into web programing
Ruby on Rails : RESTful 和 Ajax
td_mxc_rubyrails_shin
td_mxc_rubyrails_shin
Ad

Recently uploaded (20)

PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Mushroom cultivation and it's methods.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
A Presentation on Artificial Intelligence
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Getting Started with Data Integration: FME Form 101
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PPTX
1. Introduction to Computer Programming.pptx
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
Machine learning based COVID-19 study performance prediction
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
Tartificialntelligence_presentation.pptx
PDF
Encapsulation theory and applications.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
Mushroom cultivation and it's methods.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
A Presentation on Artificial Intelligence
Assigned Numbers - 2025 - Bluetooth® Document
Diabetes mellitus diagnosis method based random forest with bat algorithm
Getting Started with Data Integration: FME Form 101
Group 1 Presentation -Planning and Decision Making .pptx
Per capita expenditure prediction using model stacking based on satellite ima...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
gpt5_lecture_notes_comprehensive_20250812015547.pdf
1. Introduction to Computer Programming.pptx
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Machine learning based COVID-19 study performance prediction
Advanced methodologies resolving dimensionality complications for autism neur...
NewMind AI Weekly Chronicles - August'25-Week II
Univ-Connecticut-ChatGPT-Presentaion.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
Tartificialntelligence_presentation.pptx
Encapsulation theory and applications.pdf

Rails vs Web2py

  • 1. Rails vs Web2Py From ”Ruby On Rails” to ”Web to Python”     http://jon.is.emotionull.com
  • 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 [email protected]