SlideShare ist ein Scribd-Unternehmen logo
1 von 25
Downloaden Sie, um offline zu lesen
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
                     

Weitere ähnliche Inhalte

Was ist angesagt?

Python & Django TTT
Python & Django TTTPython & Django TTT
Python & Django TTT
kevinvw
 
Django Framework and Application Structure
Django Framework and Application StructureDjango Framework and Application Structure
Django Framework and Application Structure
SEONGTAEK OH
 
Design patterns revisited with PHP 5.3
Design patterns revisited with PHP 5.3Design patterns revisited with PHP 5.3
Design patterns revisited with PHP 5.3
Fabien Potencier
 

Was ist angesagt? (20)

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

Ähnlich wie Rails vs Web2py

How to disassemble one monster app into an ecosystem of 30
How to disassemble one monster app into an ecosystem of 30How to disassemble one monster app into an ecosystem of 30
How to disassemble one monster app into an ecosystem of 30
fiyuer
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overview
Yehuda Katz
 
TurboGears2 Pluggable Applications
TurboGears2 Pluggable ApplicationsTurboGears2 Pluggable Applications
TurboGears2 Pluggable Applications
Alessandro Molina
 
Overview of The Scala Based Lift Web Framework
Overview of The Scala Based Lift Web FrameworkOverview of The Scala Based Lift Web Framework
Overview of The Scala Based Lift Web Framework
IndicThreads
 
Scala based Lift Framework
Scala based Lift FrameworkScala based Lift Framework
Scala based Lift Framework
vhazrati
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the Finish
Yehuda Katz
 
RubyOnRails-Cheatsheet-BlaineKendall
RubyOnRails-Cheatsheet-BlaineKendallRubyOnRails-Cheatsheet-BlaineKendall
RubyOnRails-Cheatsheet-BlaineKendall
tutorialsruby
 
RubyOnRails-Cheatsheet-BlaineKendall
RubyOnRails-Cheatsheet-BlaineKendallRubyOnRails-Cheatsheet-BlaineKendall
RubyOnRails-Cheatsheet-BlaineKendall
tutorialsruby
 

Ähnlich wie Rails vs Web2py (20)

How to disassemble one monster app into an ecosystem of 30
How to disassemble one monster app into an ecosystem of 30How to disassemble one monster app into an ecosystem of 30
How to disassemble one monster app into an ecosystem of 30
 
Ruby on Rails at PROMPT ISEL '11
Ruby on Rails at PROMPT ISEL '11Ruby on Rails at PROMPT ISEL '11
Ruby on Rails at PROMPT ISEL '11
 
Play vs Rails
Play vs RailsPlay vs Rails
Play vs Rails
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overview
 
TurboGears2 Pluggable Applications
TurboGears2 Pluggable ApplicationsTurboGears2 Pluggable Applications
TurboGears2 Pluggable Applications
 
Overview Of Lift Framework
Overview Of Lift FrameworkOverview Of Lift Framework
Overview Of Lift Framework
 
Overview of The Scala Based Lift Web Framework
Overview of The Scala Based Lift Web FrameworkOverview of The Scala Based Lift Web Framework
Overview of The Scala Based Lift Web Framework
 
Scala based Lift Framework
Scala based Lift FrameworkScala based Lift Framework
Scala based Lift Framework
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the Finish
 
Play!ng with scala
Play!ng with scalaPlay!ng with scala
Play!ng with scala
 
Writing HTML5 Web Apps using Backbone.js and GAE
Writing HTML5 Web Apps using Backbone.js and GAEWriting HTML5 Web Apps using Backbone.js and GAE
Writing HTML5 Web Apps using Backbone.js and GAE
 
More to RoC weibo
More to RoC weiboMore to RoC weibo
More to RoC weibo
 
Symfony2 - from the trenches
Symfony2 - from the trenchesSymfony2 - from the trenches
Symfony2 - from the trenches
 
Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!
 
Ruby/Rails
Ruby/RailsRuby/Rails
Ruby/Rails
 
Django Vs Rails
Django Vs RailsDjango Vs Rails
Django Vs Rails
 
Getting started with Rails (2), Season 2
Getting started with Rails (2), Season 2Getting started with Rails (2), Season 2
Getting started with Rails (2), Season 2
 
RubyOnRails-Cheatsheet-BlaineKendall
RubyOnRails-Cheatsheet-BlaineKendallRubyOnRails-Cheatsheet-BlaineKendall
RubyOnRails-Cheatsheet-BlaineKendall
 
RubyOnRails-Cheatsheet-BlaineKendall
RubyOnRails-Cheatsheet-BlaineKendallRubyOnRails-Cheatsheet-BlaineKendall
RubyOnRails-Cheatsheet-BlaineKendall
 
Using and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middlewareUsing and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middleware
 

Kürzlich hochgeladen

Kürzlich hochgeladen (20)

Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 

Rails vs Web2py

  • 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