SlideShare a Scribd company logo
1 of 20
TurboGears2


                        Building
            Full Featured Web Applications
                    with TurboGears2
                 in a bunch of minutes




Alessandro Molina - @__amol__ - amol@turbogears.org
TurboGears2
● Framework for rapid development encouraging
   customization
● Object Dispatch based. Regular expressions can get
   messy, never write a regex anymore
● By default an XML template engine with error
   detection
● Declarative Models with transactional unit of work
● Built in Validation, Authentication, Authorization,
   Caching, Sessions, Migrations, MongoDB Support and
   many more.
Looking at the code
Serving /movie/3 as a webpage and /movie/3.json as
a json encoded response


class RootController(BaseController):

  @expose('myproj.templates.movie')
  @expose('json')
  @validate({'movie':SQLAEntityConverter(model.Movie)}
  def movie(self, movie, **kw):
    return dict(movie=movie, user=request.identity and request.identity['user'])
What it looks like
TurboGears for RAD
● 2.0 had sprox and tgext.crud: Flexible, but hard to use!
● 2.1 had many sprox improvements and added the
    EasyCrudRestController
●   2.1.4 had many hooks improvements that made tgext.
    pluggable possible!




With EasyCrudRestController and pluggable applications
rapid prototyping can be rapid for real
EasyCrudRestController
Aims at making possible to create full administrative
interfaces in a bunch of seconds
Easy CRUD
Minimal setup is minimal for real!


             from tgext.crud import EasyCrudRestController

             class GalleriesController(EasyCrudRestController):
               model = model.Gallery




This provides CRUD interface with Search, ordering and
autogenerated JSON Rest API for that model.
Custom CRUD
Customizing the Crud Controller can be done from the
__form_options__ and __table_options__ variables of the
class.
           class PhotosController(EasyCrudRestController):
             model = model.Photo
             allow_only = predicates.in_group('photos')
             title = "Manage Photos"
             keep_params = ['gallery']

             __form_options__ = {
               '__hide_fields__' : ['uid', 'author', 'gallery'],
               '__field_widget_types__' : {'image':FileField},
               '__field_validator_types__' : {'image':FieldStorageUploadConverter},
               '__field_widget_args__' : {'author':{'default':lambda:request.identity['user'].user_id}}
             }

             __table_options__ = {
               '__omit_fields__' : ['uid', 'author_id', 'gallery_id', 'gallery'],
               '__xml_fields__' : ['image'],
               'image': lambda filler,row: html.literal('‹img src="%s"/›' % row.image.thumb_url)
             }
Custom CRUD Result
Result is a web page to upload photos to a gallery with
uploaded image preview
Let's plug them all
CRUD tools provide a quick and easy way to prototype new
functions.

But... there are things which are not a plain CRUD, how can
you speed up their development?

Fastest solution is to have things already done by someone
else!

That's what pluggable applications are for
Pluggables
Pluggable applications provide ready made features that can
be plugged into your applications.
● Implemented as tgext.pluggable, if you don't use them
   they won't bother you
● As easy as plug(base_config, 'appname')
● They look a lot like a plain application and provide
   models, controllers, templates, helpers, partials,
   database bootstrap and so on.
● Creating one as easy as paster quickstart-pluggable
   appname
● Sadly supported only for SQLAlchemy storage backed,
   mongodb planned
Available Pluggables
tgapp-registration              tgapp-smallpress

Provides a registration     Provides multblog with
process with activation           WYSIWYG editor,
email. It's heavily        tagcloud, attachments,
customizable using                   drafts, future
hooks.                            publications and
                             Whoosh based search.




tgapp-fbauth                         tgapp-photos

facebook authentication,       Provides partials to
registration and                display photos and
connection to existing        photo galleries with
accounts.                   automatic thumbnails.
Available Pluggables
tgapp-userprofile                             libacr

Provides a basic profile       Provides a powerful
page and badge                    CMS where pages
for users with profile       are splitted into slices
picture took from                     each editable
facebook, gravatar or          and of its own type.
custom source.
                                  Custom slices and
                             new type of contents
 stroller                    can be easily created
                             directly from the CMS
 Provides eCommerce           itself without editing
 application with                             code.
 categories, multiple
 pictures for each product
 and orders management.
DebugBar
To improve developers life the first pluggable application
created has been the debugbar.
                                       ● Controller methods
                                         profiling
                                       ● Template Rendering
                                         timings
                                       ● Query inspector
                                       ● Request inspector
                                       ● and so on... The
                                         usual things you
                                         would expect from a
                                         debug bar!
Inventing Mode
How the debugbar relates to rapid prototyping?
Well, it makes life easier, but mostly... It provides the
inventing mode!

Place your browser and code editor side by side and start
experimenting, your changes will reflect into the browser in
real time and it will notify you when you broke something.
Creating pluggables
Once tgext.pluggable gets installed the quickstart-pluggable
command becames available.

Running quickstart-pluggable will create a package that
looks a lot like a TurboGears application but provides a
plugme method inside its __init__.py

plugme method is the entry point of your pluggable
application.


 def plugme(app_config, options):
   return dict(appid='plugtest', global_helpers=False)
Structure of a Pluggable
$ paster quickstart-pluggable plugtest

                                         Pluggable Applications controllers, root
                                         controller of the application is named
                                         RootController inside the root.py file and
                                         will be mounted as /plugtest

                                         Models of the pluggable applications, will
                                         be bound to the session of the master app

                                         Static files of the pluggable application,
                                         will be available at /_pluggable/plugtest




                                         Templates of the pluggable application,
                                         controllers can use them with standard
                                         expose syntax: @expose('plugtest.
                                         templates.index')
Structure of a Pluggable

           Here rely all the utility functions of the
           pluggable application. By default they are
           not exposed to the master application but
           are stille accessible as a python module

           bootstrap is automatically called when
           initializing the database of the master
           application.

           Pluggables can provide helpers which will
           be automatically available into the master
           application as h.plugtest.helpername

           Partials are evolved helpers, they provide logic
           and look like controllers with an exposed
           template. They are acceissible inside templates
           with h.call_partial('plugtest.partials:
           partialname')
Pluggable Utilities
tgext.pluggable provides a bunch of utilities that help when
working with pluggable applications to override part of their
aspect or behavior:

●   replace_template(base_config, 'otherapp.templates.about', 'myapp.
    templates.index')    permits to replace any template with another one,
    makes possible to change the look of any plugged web page
●   plug_url('plugtest', '/somewhere') makes possible to generate urls relative
    to a plugged application
●   tgext.pluggable.app_model provides the models of the application where the
    pluggable app will be plugged.
●   tgext.pluggable.primary_key(Model) detects the primary key of a model so
    that it is possible to create relations to models we don't know how they look
    like.
Join turbogears@googlegroups.com for more details!

More Related Content

What's hot

AngularJs (1.x) Presentation
AngularJs (1.x) PresentationAngularJs (1.x) Presentation
AngularJs (1.x) PresentationRaghubir Singh
 
Testdrive AngularJS with Spring 4
Testdrive AngularJS with Spring 4Testdrive AngularJS with Spring 4
Testdrive AngularJS with Spring 4Oliver Wahlen
 
What's new and exciting with JSF 2.0
What's new and exciting with JSF 2.0What's new and exciting with JSF 2.0
What's new and exciting with JSF 2.0Michael Fons
 
android design pattern
android design patternandroid design pattern
android design patternLucas Xu
 
Java Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedJava Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedBG Java EE Course
 
JSF Component Behaviors
JSF Component BehaviorsJSF Component Behaviors
JSF Component BehaviorsAndy Schwartz
 
Different way to share data between controllers in angular js
Different way to share data between controllers in angular jsDifferent way to share data between controllers in angular js
Different way to share data between controllers in angular jscodeandyou forums
 
Introduction of angular js
Introduction of angular jsIntroduction of angular js
Introduction of angular jsTamer Solieman
 
Angular JS - Introduction
Angular JS - IntroductionAngular JS - Introduction
Angular JS - IntroductionSagar Acharya
 
JSF Custom Components
JSF Custom ComponentsJSF Custom Components
JSF Custom ComponentsMichael Fons
 
Angular 8
Angular 8 Angular 8
Angular 8 Sunil OS
 
AngularJS - dependency injection
AngularJS - dependency injectionAngularJS - dependency injection
AngularJS - dependency injectionAlexe Bogdan
 
Strutsjspservlet
Strutsjspservlet Strutsjspservlet
Strutsjspservlet Sagar Nakul
 

What's hot (20)

AngularJs (1.x) Presentation
AngularJs (1.x) PresentationAngularJs (1.x) Presentation
AngularJs (1.x) Presentation
 
Testdrive AngularJS with Spring 4
Testdrive AngularJS with Spring 4Testdrive AngularJS with Spring 4
Testdrive AngularJS with Spring 4
 
What's new and exciting with JSF 2.0
What's new and exciting with JSF 2.0What's new and exciting with JSF 2.0
What's new and exciting with JSF 2.0
 
android design pattern
android design patternandroid design pattern
android design pattern
 
Java Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedJava Server Faces (JSF) - advanced
Java Server Faces (JSF) - advanced
 
JSF Component Behaviors
JSF Component BehaviorsJSF Component Behaviors
JSF Component Behaviors
 
Different way to share data between controllers in angular js
Different way to share data between controllers in angular jsDifferent way to share data between controllers in angular js
Different way to share data between controllers in angular js
 
Introduction of angular js
Introduction of angular jsIntroduction of angular js
Introduction of angular js
 
Angular JS - Introduction
Angular JS - IntroductionAngular JS - Introduction
Angular JS - Introduction
 
JSF Custom Components
JSF Custom ComponentsJSF Custom Components
JSF Custom Components
 
Introduction to Angularjs
Introduction to AngularjsIntroduction to Angularjs
Introduction to Angularjs
 
Angular 8
Angular 8 Angular 8
Angular 8
 
Building richwebapplicationsusingasp
Building richwebapplicationsusingaspBuilding richwebapplicationsusingasp
Building richwebapplicationsusingasp
 
Jsf intro
Jsf introJsf intro
Jsf intro
 
Advance RCP
Advance RCPAdvance RCP
Advance RCP
 
AngularJS - dependency injection
AngularJS - dependency injectionAngularJS - dependency injection
AngularJS - dependency injection
 
Mean stack Magics
Mean stack MagicsMean stack Magics
Mean stack Magics
 
AngularJS in practice
AngularJS in practiceAngularJS in practice
AngularJS in practice
 
Java server faces
Java server facesJava server faces
Java server faces
 
Strutsjspservlet
Strutsjspservlet Strutsjspservlet
Strutsjspservlet
 

Similar to Rapid Prototyping with TurboGears2

Introduction to django framework
Introduction to django frameworkIntroduction to django framework
Introduction to django frameworkKnoldus Inc.
 
Company Visitor Management System Report.docx
Company Visitor Management System Report.docxCompany Visitor Management System Report.docx
Company Visitor Management System Report.docxfantabulous2024
 
بررسی چارچوب جنگو
بررسی چارچوب جنگوبررسی چارچوب جنگو
بررسی چارچوب جنگوrailsbootcamp
 
AngularJS Project Setup step-by- step guide - RapidValue Solutions
AngularJS Project Setup step-by- step guide - RapidValue SolutionsAngularJS Project Setup step-by- step guide - RapidValue Solutions
AngularJS Project Setup step-by- step guide - RapidValue SolutionsRapidValue
 
Advanced Dagger talk from 360andev
Advanced Dagger talk from 360andevAdvanced Dagger talk from 360andev
Advanced Dagger talk from 360andevMike Nakhimovich
 
TangoWithDjango - ch8
TangoWithDjango - ch8TangoWithDjango - ch8
TangoWithDjango - ch8Asika Kuo
 
How to Implement Micro Frontend Architecture using Angular Framework
How to Implement Micro Frontend Architecture using Angular FrameworkHow to Implement Micro Frontend Architecture using Angular Framework
How to Implement Micro Frontend Architecture using Angular FrameworkRapidValue
 
Ultimate Guide to Microservice Architecture on Kubernetes
Ultimate Guide to Microservice Architecture on KubernetesUltimate Guide to Microservice Architecture on Kubernetes
Ultimate Guide to Microservice Architecture on Kuberneteskloia
 
Drools & jBPM Info Sheet
Drools & jBPM Info SheetDrools & jBPM Info Sheet
Drools & jBPM Info SheetMark Proctor
 
Web worker in your angular application
Web worker in your angular applicationWeb worker in your angular application
Web worker in your angular applicationSuresh Patidar
 
Introduction To Eclipse RCP
Introduction To Eclipse RCPIntroduction To Eclipse RCP
Introduction To Eclipse RCPwhbath
 
Front end development with Angular JS
Front end development with Angular JSFront end development with Angular JS
Front end development with Angular JSBipin
 

Similar to Rapid Prototyping with TurboGears2 (20)

Introduction to django framework
Introduction to django frameworkIntroduction to django framework
Introduction to django framework
 
Spring boot
Spring bootSpring boot
Spring boot
 
Company Visitor Management System Report.docx
Company Visitor Management System Report.docxCompany Visitor Management System Report.docx
Company Visitor Management System Report.docx
 
Basic Python Django
Basic Python DjangoBasic Python Django
Basic Python Django
 
بررسی چارچوب جنگو
بررسی چارچوب جنگوبررسی چارچوب جنگو
بررسی چارچوب جنگو
 
Introduction to Angular Js
Introduction to Angular JsIntroduction to Angular Js
Introduction to Angular Js
 
AngularJS Project Setup step-by- step guide - RapidValue Solutions
AngularJS Project Setup step-by- step guide - RapidValue SolutionsAngularJS Project Setup step-by- step guide - RapidValue Solutions
AngularJS Project Setup step-by- step guide - RapidValue Solutions
 
Advanced Dagger talk from 360andev
Advanced Dagger talk from 360andevAdvanced Dagger talk from 360andev
Advanced Dagger talk from 360andev
 
TangoWithDjango - ch8
TangoWithDjango - ch8TangoWithDjango - ch8
TangoWithDjango - ch8
 
How to Implement Micro Frontend Architecture using Angular Framework
How to Implement Micro Frontend Architecture using Angular FrameworkHow to Implement Micro Frontend Architecture using Angular Framework
How to Implement Micro Frontend Architecture using Angular Framework
 
Django by rj
Django by rjDjango by rj
Django by rj
 
Ultimate Guide to Microservice Architecture on Kubernetes
Ultimate Guide to Microservice Architecture on KubernetesUltimate Guide to Microservice Architecture on Kubernetes
Ultimate Guide to Microservice Architecture on Kubernetes
 
Drools & jBPM Info Sheet
Drools & jBPM Info SheetDrools & jBPM Info Sheet
Drools & jBPM Info Sheet
 
React django
React djangoReact django
React django
 
Web worker in your angular application
Web worker in your angular applicationWeb worker in your angular application
Web worker in your angular application
 
Android crash course
Android crash courseAndroid crash course
Android crash course
 
Codeigniter
CodeigniterCodeigniter
Codeigniter
 
Introduction To Eclipse RCP
Introduction To Eclipse RCPIntroduction To Eclipse RCP
Introduction To Eclipse RCP
 
Angular js-crash-course
Angular js-crash-courseAngular js-crash-course
Angular js-crash-course
 
Front end development with Angular JS
Front end development with Angular JSFront end development with Angular JS
Front end development with Angular JS
 

More from Alessandro Molina

PyCon Ireland 2022 - PyArrow full stack.pdf
PyCon Ireland 2022 - PyArrow full stack.pdfPyCon Ireland 2022 - PyArrow full stack.pdf
PyCon Ireland 2022 - PyArrow full stack.pdfAlessandro Molina
 
PyconIE 2016 - Kajiki, the fast and validated template engine your were looki...
PyconIE 2016 - Kajiki, the fast and validated template engine your were looki...PyconIE 2016 - Kajiki, the fast and validated template engine your were looki...
PyconIE 2016 - Kajiki, the fast and validated template engine your were looki...Alessandro Molina
 
EP2016 - Moving Away From Nodejs To A Pure Python Solution For Assets
EP2016 - Moving Away From Nodejs To A Pure Python Solution For AssetsEP2016 - Moving Away From Nodejs To A Pure Python Solution For Assets
EP2016 - Moving Away From Nodejs To A Pure Python Solution For AssetsAlessandro Molina
 
EuroPython 2015 - Storing files for the web is not as straightforward as you ...
EuroPython 2015 - Storing files for the web is not as straightforward as you ...EuroPython 2015 - Storing files for the web is not as straightforward as you ...
EuroPython 2015 - Storing files for the web is not as straightforward as you ...Alessandro Molina
 
PyConIT6 - MAKING SESSIONS AND CACHING ROOMMATES
PyConIT6 - MAKING SESSIONS AND CACHING ROOMMATESPyConIT6 - MAKING SESSIONS AND CACHING ROOMMATES
PyConIT6 - MAKING SESSIONS AND CACHING ROOMMATESAlessandro Molina
 
PyConIT6 - Messing up with pymongo for fun and profit
PyConIT6 - Messing up with pymongo for fun and profitPyConIT6 - Messing up with pymongo for fun and profit
PyConIT6 - Messing up with pymongo for fun and profitAlessandro Molina
 
PyConFR 2014 - DEPOT, Story of a file.write() gone wrong
PyConFR 2014 - DEPOT, Story of a file.write() gone wrongPyConFR 2014 - DEPOT, Story of a file.write() gone wrong
PyConFR 2014 - DEPOT, Story of a file.write() gone wrongAlessandro Molina
 
PyConUK 2014 - PostMortem Debugging and Web Development Updated
PyConUK 2014 - PostMortem Debugging and Web Development UpdatedPyConUK 2014 - PostMortem Debugging and Web Development Updated
PyConUK 2014 - PostMortem Debugging and Web Development UpdatedAlessandro Molina
 
Reactive & Realtime Web Applications with TurboGears2
Reactive & Realtime Web Applications with TurboGears2Reactive & Realtime Web Applications with TurboGears2
Reactive & Realtime Web Applications with TurboGears2Alessandro Molina
 
Post-Mortem Debugging and Web Development
Post-Mortem Debugging and Web DevelopmentPost-Mortem Debugging and Web Development
Post-Mortem Debugging and Web DevelopmentAlessandro Molina
 
MongoTorino 2013 - BSON Mad Science for fun and profit
MongoTorino 2013 - BSON Mad Science for fun and profitMongoTorino 2013 - BSON Mad Science for fun and profit
MongoTorino 2013 - BSON Mad Science for fun and profitAlessandro Molina
 
PyConUK2013 - Validated documents on MongoDB with Ming
PyConUK2013 - Validated documents on MongoDB with MingPyConUK2013 - Validated documents on MongoDB with Ming
PyConUK2013 - Validated documents on MongoDB with MingAlessandro Molina
 
EuroPython 2013 - FAST, DOCUMENTED AND RELIABLE JSON BASED WEBSERVICES WITH P...
EuroPython 2013 - FAST, DOCUMENTED AND RELIABLE JSON BASED WEBSERVICES WITH P...EuroPython 2013 - FAST, DOCUMENTED AND RELIABLE JSON BASED WEBSERVICES WITH P...
EuroPython 2013 - FAST, DOCUMENTED AND RELIABLE JSON BASED WEBSERVICES WITH P...Alessandro Molina
 
EuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears TrainingEuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears TrainingAlessandro Molina
 
PyGrunn2013 High Performance Web Applications with TurboGears
PyGrunn2013  High Performance Web Applications with TurboGearsPyGrunn2013  High Performance Web Applications with TurboGears
PyGrunn2013 High Performance Web Applications with TurboGearsAlessandro Molina
 
TurboGears2 Pluggable Applications
TurboGears2 Pluggable ApplicationsTurboGears2 Pluggable Applications
TurboGears2 Pluggable ApplicationsAlessandro Molina
 
From SQLAlchemy to Ming with TurboGears2
From SQLAlchemy to Ming with TurboGears2From SQLAlchemy to Ming with TurboGears2
From SQLAlchemy to Ming with TurboGears2Alessandro Molina
 

More from Alessandro Molina (17)

PyCon Ireland 2022 - PyArrow full stack.pdf
PyCon Ireland 2022 - PyArrow full stack.pdfPyCon Ireland 2022 - PyArrow full stack.pdf
PyCon Ireland 2022 - PyArrow full stack.pdf
 
PyconIE 2016 - Kajiki, the fast and validated template engine your were looki...
PyconIE 2016 - Kajiki, the fast and validated template engine your were looki...PyconIE 2016 - Kajiki, the fast and validated template engine your were looki...
PyconIE 2016 - Kajiki, the fast and validated template engine your were looki...
 
EP2016 - Moving Away From Nodejs To A Pure Python Solution For Assets
EP2016 - Moving Away From Nodejs To A Pure Python Solution For AssetsEP2016 - Moving Away From Nodejs To A Pure Python Solution For Assets
EP2016 - Moving Away From Nodejs To A Pure Python Solution For Assets
 
EuroPython 2015 - Storing files for the web is not as straightforward as you ...
EuroPython 2015 - Storing files for the web is not as straightforward as you ...EuroPython 2015 - Storing files for the web is not as straightforward as you ...
EuroPython 2015 - Storing files for the web is not as straightforward as you ...
 
PyConIT6 - MAKING SESSIONS AND CACHING ROOMMATES
PyConIT6 - MAKING SESSIONS AND CACHING ROOMMATESPyConIT6 - MAKING SESSIONS AND CACHING ROOMMATES
PyConIT6 - MAKING SESSIONS AND CACHING ROOMMATES
 
PyConIT6 - Messing up with pymongo for fun and profit
PyConIT6 - Messing up with pymongo for fun and profitPyConIT6 - Messing up with pymongo for fun and profit
PyConIT6 - Messing up with pymongo for fun and profit
 
PyConFR 2014 - DEPOT, Story of a file.write() gone wrong
PyConFR 2014 - DEPOT, Story of a file.write() gone wrongPyConFR 2014 - DEPOT, Story of a file.write() gone wrong
PyConFR 2014 - DEPOT, Story of a file.write() gone wrong
 
PyConUK 2014 - PostMortem Debugging and Web Development Updated
PyConUK 2014 - PostMortem Debugging and Web Development UpdatedPyConUK 2014 - PostMortem Debugging and Web Development Updated
PyConUK 2014 - PostMortem Debugging and Web Development Updated
 
Reactive & Realtime Web Applications with TurboGears2
Reactive & Realtime Web Applications with TurboGears2Reactive & Realtime Web Applications with TurboGears2
Reactive & Realtime Web Applications with TurboGears2
 
Post-Mortem Debugging and Web Development
Post-Mortem Debugging and Web DevelopmentPost-Mortem Debugging and Web Development
Post-Mortem Debugging and Web Development
 
MongoTorino 2013 - BSON Mad Science for fun and profit
MongoTorino 2013 - BSON Mad Science for fun and profitMongoTorino 2013 - BSON Mad Science for fun and profit
MongoTorino 2013 - BSON Mad Science for fun and profit
 
PyConUK2013 - Validated documents on MongoDB with Ming
PyConUK2013 - Validated documents on MongoDB with MingPyConUK2013 - Validated documents on MongoDB with Ming
PyConUK2013 - Validated documents on MongoDB with Ming
 
EuroPython 2013 - FAST, DOCUMENTED AND RELIABLE JSON BASED WEBSERVICES WITH P...
EuroPython 2013 - FAST, DOCUMENTED AND RELIABLE JSON BASED WEBSERVICES WITH P...EuroPython 2013 - FAST, DOCUMENTED AND RELIABLE JSON BASED WEBSERVICES WITH P...
EuroPython 2013 - FAST, DOCUMENTED AND RELIABLE JSON BASED WEBSERVICES WITH P...
 
EuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears TrainingEuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears Training
 
PyGrunn2013 High Performance Web Applications with TurboGears
PyGrunn2013  High Performance Web Applications with TurboGearsPyGrunn2013  High Performance Web Applications with TurboGears
PyGrunn2013 High Performance Web Applications with TurboGears
 
TurboGears2 Pluggable Applications
TurboGears2 Pluggable ApplicationsTurboGears2 Pluggable Applications
TurboGears2 Pluggable Applications
 
From SQLAlchemy to Ming with TurboGears2
From SQLAlchemy to Ming with TurboGears2From SQLAlchemy to Ming with TurboGears2
From SQLAlchemy to Ming with TurboGears2
 

Recently uploaded

Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 

Recently uploaded (20)

Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 

Rapid Prototyping with TurboGears2

  • 1. TurboGears2 Building Full Featured Web Applications with TurboGears2 in a bunch of minutes Alessandro Molina - @__amol__ - amol@turbogears.org
  • 2. TurboGears2 ● Framework for rapid development encouraging customization ● Object Dispatch based. Regular expressions can get messy, never write a regex anymore ● By default an XML template engine with error detection ● Declarative Models with transactional unit of work ● Built in Validation, Authentication, Authorization, Caching, Sessions, Migrations, MongoDB Support and many more.
  • 3. Looking at the code Serving /movie/3 as a webpage and /movie/3.json as a json encoded response class RootController(BaseController): @expose('myproj.templates.movie') @expose('json') @validate({'movie':SQLAEntityConverter(model.Movie)} def movie(self, movie, **kw): return dict(movie=movie, user=request.identity and request.identity['user'])
  • 5. TurboGears for RAD ● 2.0 had sprox and tgext.crud: Flexible, but hard to use! ● 2.1 had many sprox improvements and added the EasyCrudRestController ● 2.1.4 had many hooks improvements that made tgext. pluggable possible! With EasyCrudRestController and pluggable applications rapid prototyping can be rapid for real
  • 6. EasyCrudRestController Aims at making possible to create full administrative interfaces in a bunch of seconds
  • 7. Easy CRUD Minimal setup is minimal for real! from tgext.crud import EasyCrudRestController class GalleriesController(EasyCrudRestController): model = model.Gallery This provides CRUD interface with Search, ordering and autogenerated JSON Rest API for that model.
  • 8. Custom CRUD Customizing the Crud Controller can be done from the __form_options__ and __table_options__ variables of the class. class PhotosController(EasyCrudRestController): model = model.Photo allow_only = predicates.in_group('photos') title = "Manage Photos" keep_params = ['gallery'] __form_options__ = { '__hide_fields__' : ['uid', 'author', 'gallery'], '__field_widget_types__' : {'image':FileField}, '__field_validator_types__' : {'image':FieldStorageUploadConverter}, '__field_widget_args__' : {'author':{'default':lambda:request.identity['user'].user_id}} } __table_options__ = { '__omit_fields__' : ['uid', 'author_id', 'gallery_id', 'gallery'], '__xml_fields__' : ['image'], 'image': lambda filler,row: html.literal('‹img src="%s"/›' % row.image.thumb_url) }
  • 9. Custom CRUD Result Result is a web page to upload photos to a gallery with uploaded image preview
  • 10. Let's plug them all CRUD tools provide a quick and easy way to prototype new functions. But... there are things which are not a plain CRUD, how can you speed up their development? Fastest solution is to have things already done by someone else! That's what pluggable applications are for
  • 11. Pluggables Pluggable applications provide ready made features that can be plugged into your applications. ● Implemented as tgext.pluggable, if you don't use them they won't bother you ● As easy as plug(base_config, 'appname') ● They look a lot like a plain application and provide models, controllers, templates, helpers, partials, database bootstrap and so on. ● Creating one as easy as paster quickstart-pluggable appname ● Sadly supported only for SQLAlchemy storage backed, mongodb planned
  • 12. Available Pluggables tgapp-registration tgapp-smallpress Provides a registration Provides multblog with process with activation WYSIWYG editor, email. It's heavily tagcloud, attachments, customizable using drafts, future hooks. publications and Whoosh based search. tgapp-fbauth tgapp-photos facebook authentication, Provides partials to registration and display photos and connection to existing photo galleries with accounts. automatic thumbnails.
  • 13. Available Pluggables tgapp-userprofile libacr Provides a basic profile Provides a powerful page and badge CMS where pages for users with profile are splitted into slices picture took from each editable facebook, gravatar or and of its own type. custom source. Custom slices and new type of contents stroller can be easily created directly from the CMS Provides eCommerce itself without editing application with code. categories, multiple pictures for each product and orders management.
  • 14. DebugBar To improve developers life the first pluggable application created has been the debugbar. ● Controller methods profiling ● Template Rendering timings ● Query inspector ● Request inspector ● and so on... The usual things you would expect from a debug bar!
  • 15. Inventing Mode How the debugbar relates to rapid prototyping? Well, it makes life easier, but mostly... It provides the inventing mode! Place your browser and code editor side by side and start experimenting, your changes will reflect into the browser in real time and it will notify you when you broke something.
  • 16. Creating pluggables Once tgext.pluggable gets installed the quickstart-pluggable command becames available. Running quickstart-pluggable will create a package that looks a lot like a TurboGears application but provides a plugme method inside its __init__.py plugme method is the entry point of your pluggable application. def plugme(app_config, options): return dict(appid='plugtest', global_helpers=False)
  • 17. Structure of a Pluggable $ paster quickstart-pluggable plugtest Pluggable Applications controllers, root controller of the application is named RootController inside the root.py file and will be mounted as /plugtest Models of the pluggable applications, will be bound to the session of the master app Static files of the pluggable application, will be available at /_pluggable/plugtest Templates of the pluggable application, controllers can use them with standard expose syntax: @expose('plugtest. templates.index')
  • 18. Structure of a Pluggable Here rely all the utility functions of the pluggable application. By default they are not exposed to the master application but are stille accessible as a python module bootstrap is automatically called when initializing the database of the master application. Pluggables can provide helpers which will be automatically available into the master application as h.plugtest.helpername Partials are evolved helpers, they provide logic and look like controllers with an exposed template. They are acceissible inside templates with h.call_partial('plugtest.partials: partialname')
  • 19. Pluggable Utilities tgext.pluggable provides a bunch of utilities that help when working with pluggable applications to override part of their aspect or behavior: ● replace_template(base_config, 'otherapp.templates.about', 'myapp. templates.index') permits to replace any template with another one, makes possible to change the look of any plugged web page ● plug_url('plugtest', '/somewhere') makes possible to generate urls relative to a plugged application ● tgext.pluggable.app_model provides the models of the application where the pluggable app will be plugged. ● tgext.pluggable.primary_key(Model) detects the primary key of a model so that it is possible to create relations to models we don't know how they look like.