SlideShare a Scribd company logo
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) Presentation
Raghubir Singh
 
Testdrive AngularJS with Spring 4
Testdrive AngularJS with Spring 4Testdrive AngularJS with Spring 4
Testdrive AngularJS with Spring 4
Oliver 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.0
Michael Fons
 
android design pattern
android design patternandroid design pattern
android design pattern
Lucas Xu
 
Java Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedJava Server Faces (JSF) - advanced
Java Server Faces (JSF) - advanced
BG Java EE Course
 
JSF Component Behaviors
JSF Component BehaviorsJSF Component Behaviors
JSF Component Behaviors
Andy 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 js
codeandyou forums
 
Introduction of angular js
Introduction of angular jsIntroduction of angular js
Introduction of angular js
Tamer Solieman
 
Angular JS - Introduction
Angular JS - IntroductionAngular JS - Introduction
Angular JS - Introduction
Sagar Acharya
 
JSF Custom Components
JSF Custom ComponentsJSF Custom Components
JSF Custom Components
Michael Fons
 
Introduction to Angularjs
Introduction to AngularjsIntroduction to Angularjs
Introduction to Angularjs
Manish Shekhawat
 
Angular 8
Angular 8 Angular 8
Angular 8
Sunil OS
 
Building richwebapplicationsusingasp
Building richwebapplicationsusingaspBuilding richwebapplicationsusingasp
Building richwebapplicationsusingasp
Giovanni Javier Jimenez Cadena
 
Jsf intro
Jsf introJsf intro
Jsf intro
vantinhkhuc
 
Advance RCP
Advance RCPAdvance RCP
Advance RCP
Rahul Shukla
 
AngularJS - dependency injection
AngularJS - dependency injectionAngularJS - dependency injection
AngularJS - dependency injection
Alexe Bogdan
 
Mean stack Magics
Mean stack MagicsMean stack Magics
Mean stack Magics
Aishura Aishu
 
AngularJS in practice
AngularJS in practiceAngularJS in practice
AngularJS in practice
Eugene Fidelin
 
Java server faces
Java server facesJava server faces
Java server faces
Fábio Santos
 
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 framework
Knoldus Inc.
 
Spring boot
Spring bootSpring boot
Company Visitor Management System Report.docx
Company Visitor Management System Report.docxCompany Visitor Management System Report.docx
Company Visitor Management System Report.docx
fantabulous2024
 
Basic Python Django
Basic Python DjangoBasic Python Django
Basic Python Django
Kaleem Ullah Mangrio
 
بررسی چارچوب جنگو
بررسی چارچوب جنگوبررسی چارچوب جنگو
بررسی چارچوب جنگو
railsbootcamp
 
Introduction to Angular Js
Introduction to Angular JsIntroduction to Angular Js
Introduction to Angular Js
Professional Guru
 
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
RapidValue
 
Advanced Dagger talk from 360andev
Advanced Dagger talk from 360andevAdvanced Dagger talk from 360andev
Advanced Dagger talk from 360andev
Mike Nakhimovich
 
TangoWithDjango - ch8
TangoWithDjango - ch8TangoWithDjango - ch8
TangoWithDjango - ch8
Asika 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 Framework
RapidValue
 
Django by rj
Django by rjDjango 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
kloia
 
Drools & jBPM Info Sheet
Drools & jBPM Info SheetDrools & jBPM Info Sheet
Drools & jBPM Info Sheet
Mark Proctor
 
React django
React djangoReact django
React django
Heber Silva
 
Web worker in your angular application
Web worker in your angular applicationWeb worker in your angular application
Web worker in your angular application
Suresh Patidar
 
Android crash course
Android crash courseAndroid crash course
Android crash course
Showmax Engineering
 
Codeigniter
CodeigniterCodeigniter
Codeigniter
Chirag Parmar
 
Introduction To Eclipse RCP
Introduction To Eclipse RCPIntroduction To Eclipse RCP
Introduction To Eclipse RCP
whbath
 
Angular js-crash-course
Angular js-crash-courseAngular js-crash-course
Angular js-crash-course
Keith Bloomfield
 
Front end development with Angular JS
Front end development with Angular JSFront end development with Angular JS
Front end development with Angular JS
Bipin
 

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.pdf
Alessandro 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 Assets
Alessandro 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 ROOMMATES
Alessandro 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 profit
Alessandro 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 wrong
Alessandro 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 Updated
Alessandro Molina
 
Reactive & Realtime Web Applications with TurboGears2
Reactive & Realtime Web Applications with TurboGears2Reactive & Realtime Web Applications with TurboGears2
Reactive & Realtime Web Applications with TurboGears2
Alessandro Molina
 
Post-Mortem Debugging and Web Development
Post-Mortem Debugging and Web DevelopmentPost-Mortem Debugging and Web Development
Post-Mortem Debugging and Web Development
Alessandro 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 profit
Alessandro 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 Ming
Alessandro 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 Training
Alessandro 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 TurboGears
Alessandro Molina
 
TurboGears2 Pluggable Applications
TurboGears2 Pluggable ApplicationsTurboGears2 Pluggable Applications
TurboGears2 Pluggable Applications
Alessandro Molina
 
From SQLAlchemy to Ming with TurboGears2
From SQLAlchemy to Ming with TurboGears2From SQLAlchemy to Ming with TurboGears2
From SQLAlchemy to Ming with TurboGears2
Alessandro 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

How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Zilliz
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
Rohit Gautam
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
Pixlogix Infotech
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 

Recently uploaded (20)

How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 

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.