SlideShare uma empresa Scribd logo
1 de 44
Enjoy your development Nicolas CLAIRON http://twitter.com/namlook #mongofr
Introducing...
 
 
A python ODM for MongoDB
Underlying philosophy
Underlying philosophy light and powerful simple fast
Document class structure
class   MyDocument (Document) : Structure Options Descriptors
class   MyDocument (Document) : structure = { 'foo' :  int , 'bar' :  float , 'spam' :{ 'eggs' : [ unicode ], 'blah' :  None , } } Options Descriptors
class   MyVeryNestedDoc (Document): structure = { '1' :{ '2' :{ '3' :{ '4' :{ '5' :{ '6' :{ '7' : int , '8' :{ '9' : float , } } } } } } } }
class   MyDocument (Document) : structure = { 'foo' :  unicode , 'bar' :  int , 'spam' :{ 'eggs' : [ unicode ], 'blah' :  float , } } Options Descriptors
class   MyDocument (Document) : structure = { 'foo' :  unicode , 'bar' :  int , 'spam' :{ 'eggs' : [ unicode ], 'blah' :  float , } } required = [ 'foo' ,  'spam.eggs' ] default_values = { 'spam.blah'  : 1.0} validators = { 'bar' : lambda  x >0} Options
class   MyDocument (Document) : structure = { 'foo' :  unicode , 'bar' :  int , 'spam' :{ 'eggs' : [ unicode ], 'blah' :  float , } } required = [ 'foo' ,  'spam.eggs' ] default_values = { 'spam.blah'  : 1.0} validators = { 'bar' : lambda  x >0} use_dot_notation =  True skip_validation =  True
Advantages ,[object Object]
Simple  python dict
Pure  python types
Nested  and complex schema declaration
Fast  : don't instanciate objects
Live  update via instrospection
Dynamic  keys
Dynamic keys class   MobilePhones (Document) : structure = { 'os'  : { unicode :[{ 'version' :  float ,  'name' : unicode }], } { 'os'  : { 'android' :[ { 'version' :  2.2 ,  'name'  : 'froyo' }, { 'version' :  2.1 ,  'name'  : 'eclair' } ], 'iphone' :[{ 'version' :  4 ,  'name'  : 'iOS' }], }
It's all about Pymongo
[object Object]
Use the same syntax
[object Object]
Use the same syntax ,[object Object]
Learn fast
One syntax to rule them all
>>> from mongokit import * >>> con = Connection()
>>> from mongokit import * >>> con = Connection() Pymongo's way >>> doc = con.mydb.mycol.find_one()  # very fast ! # doc is a dict instance
>>> from mongokit import * >>> con = Connection() Pymongo's way >>> doc = con.mydb.mycol.find_one()  # very fast ! # doc is a dict instance Mongokit's way >>> doc = con.mydb.mycol.MyDocument.find_one() # doc is a MyDocument instance >>> doc.spam.eggs.append(u'foo') >>> doc.save()
Features
Inheriance / Polymorphism class   A (Document) : structure = { 'a' : { 'foo'  :  unicode , } } class   B (Document) : structure = { 'b' : { 'bar'  : [ float ] , } }
Inheriance / Polymorphism class   A (Document) : structure = { 'a' : { 'foo'  :  unicode , } } class   B (Document) : structure = { 'b' : { 'bar'  : [ float ] , } } class   C (A,B) : structure = { 'c' : { 'spam'  :  int , } }
Inheriance / Polymorphism class   A (Document) : structure = { 'a' : { 'foo'  :  unicode , } } class   B (Document) : structure = { 'b' : { 'bar'  : [ float ] , } } class   C (A,B) : structure = { 'c' : { 'spam'  :  int , } } { 'a'  : { 'foo'  :  None }, 'b'  : { 'bar'  :  [] }, 'c'  : { 'spam'  :  None } } >>> con.mydb.mycol.C()
Dot notation class   MyDocument (Document) : structure = { 'foo' :  unicode , 'bar' :  int , 'spam' :{ 'eggs' : [ unicode ], 'blah' :  float , } }
Dot notation class   MyDocument (Document) : structure = { 'foo' :  unicode , 'bar' :  int , 'spam' :{ 'eggs' : [ unicode ], 'blah' :  float , } } use_dot_notation = True
Dot notation class   MyDocument (Document) : structure = { 'foo' :  unicode , 'bar' :  int , 'spam' :{ 'eggs' : [ unicode ], 'blah' :  float , } } use_dot_notation = True >>> doc = con.mydb.mycol.MyDocument() >>> doc.foo = u'the foo' >>> doc.spam.eggs.append(u'bla', u'toto')
Document reference class   Comment (Document) : structure = { 'title' :  unicode 'body' :  unicode , 'author'  : ObjectId, } class   User (Document) : structure = { 'login' :  unicode , 'name' :  unicode , }
Document reference class   Comment (Document) : structure = { 'title' :  unicode 'body' :  unicode , 'author'  :  User , } use_autorefs = True class   User (Document) : structure = { 'login' :  unicode , 'name' :  unicode , }
Document reference class   Comment (Document) : structure = { 'title' :  unicode 'body' :  unicode , 'author'  : User, } use_autorefs = True class   User (Document) : structure = { 'login' :  unicode , 'name' :  unicode , } { 'title' : 'Hello world !', 'body' : 'My first blog post', 'author' : DBRef(...), } >>> con.mydb.mycol.find_one()
Document reference class   Comment (Document) : structure = { 'title' :  unicode 'body' :  unicode , 'author'  : User, } use_autorefs = True class   User (Document) : structure = { 'login' :  unicode , 'name' :  unicode , } { 'title' : 'Hello world !', 'body' : 'My first blog post', 'author' : DBRef(...), } >>> con.mydb.mycol.find_one() { 'title' : 'Hello world !', 'body' : 'My first blog post', 'author' : { 'login' : 'timy', 'name' : 'Timy Donzy' } } >>> con.mydb.mycol.BlogPost.find_one()
GridFS support class   MyDocument (Document) : structure = { 'foo' :  unicode , 'bar' :  int , } grid_fs = { 'files' :[ 'source' ,  'template' ], 'containers' : [ 'images' ], } >>> doc = con.mydb.mycol.MyDocument() >>> doc.fs.source = '...' >>> doc.fs.images['image1.png'] = '…'

Mais conteúdo relacionado

Mais procurados

06. ElasticSearch : Mapping and Analysis
06. ElasticSearch : Mapping and Analysis06. ElasticSearch : Mapping and Analysis
06. ElasticSearch : Mapping and AnalysisOpenThink Labs
 
파이썬 플라스크로 배우는 웹프로그래밍 #2 (ABCD)
파이썬 플라스크로 배우는 웹프로그래밍 #2 (ABCD)파이썬 플라스크로 배우는 웹프로그래밍 #2 (ABCD)
파이썬 플라스크로 배우는 웹프로그래밍 #2 (ABCD)성일 한
 
The Ruby/mongoDB ecosystem
The Ruby/mongoDB ecosystemThe Ruby/mongoDB ecosystem
The Ruby/mongoDB ecosystemHarold Giménez
 
The FPDF Library
The FPDF LibraryThe FPDF Library
The FPDF LibraryDave Ross
 
Ods Markup And Tagsets: A Tutorial
Ods Markup And Tagsets: A TutorialOds Markup And Tagsets: A Tutorial
Ods Markup And Tagsets: A Tutorialsimienc
 
OSS BarCamp Mumbai - JSON Presentation and Demo
OSS BarCamp Mumbai - JSON Presentation and DemoOSS BarCamp Mumbai - JSON Presentation and Demo
OSS BarCamp Mumbai - JSON Presentation and DemoKetan Khairnar
 

Mais procurados (10)

06. ElasticSearch : Mapping and Analysis
06. ElasticSearch : Mapping and Analysis06. ElasticSearch : Mapping and Analysis
06. ElasticSearch : Mapping and Analysis
 
파이썬 플라스크로 배우는 웹프로그래밍 #2 (ABCD)
파이썬 플라스크로 배우는 웹프로그래밍 #2 (ABCD)파이썬 플라스크로 배우는 웹프로그래밍 #2 (ABCD)
파이썬 플라스크로 배우는 웹프로그래밍 #2 (ABCD)
 
The Ruby/mongoDB ecosystem
The Ruby/mongoDB ecosystemThe Ruby/mongoDB ecosystem
The Ruby/mongoDB ecosystem
 
The FPDF Library
The FPDF LibraryThe FPDF Library
The FPDF Library
 
Having Fun Programming!
Having Fun Programming!Having Fun Programming!
Having Fun Programming!
 
Ods Markup And Tagsets: A Tutorial
Ods Markup And Tagsets: A TutorialOds Markup And Tagsets: A Tutorial
Ods Markup And Tagsets: A Tutorial
 
OSS BarCamp Mumbai - JSON Presentation and Demo
OSS BarCamp Mumbai - JSON Presentation and DemoOSS BarCamp Mumbai - JSON Presentation and Demo
OSS BarCamp Mumbai - JSON Presentation and Demo
 
Lettering js
Lettering jsLettering js
Lettering js
 
Mongo learning series
Mongo learning series Mongo learning series
Mongo learning series
 
Using Dojo
Using DojoUsing Dojo
Using Dojo
 

Semelhante a Mongokit presentation mongofr-2010

Python - Getting to the Essence - Points.com - Dave Park
Python - Getting to the Essence - Points.com - Dave ParkPython - Getting to the Essence - Points.com - Dave Park
Python - Getting to the Essence - Points.com - Dave Parkpointstechgeeks
 
External Data Access with jQuery
External Data Access with jQueryExternal Data Access with jQuery
External Data Access with jQueryDoncho Minkov
 
Rapid and Scalable Development with MongoDB, PyMongo, and Ming
Rapid and Scalable Development with MongoDB, PyMongo, and MingRapid and Scalable Development with MongoDB, PyMongo, and Ming
Rapid and Scalable Development with MongoDB, PyMongo, and MingRick Copeland
 
Integrate CI/CD Pipelines with Jira Software Cloud
Integrate CI/CD Pipelines with Jira Software CloudIntegrate CI/CD Pipelines with Jira Software Cloud
Integrate CI/CD Pipelines with Jira Software CloudAtlassian
 
Plone For Developers - World Plone Day, 2009
Plone For Developers - World Plone Day, 2009Plone For Developers - World Plone Day, 2009
Plone For Developers - World Plone Day, 2009Core Software Group
 
Architecture | Busy Java Developers Guide to NoSQL | Ted Neward
Architecture | Busy Java Developers Guide to NoSQL | Ted NewardArchitecture | Busy Java Developers Guide to NoSQL | Ted Neward
Architecture | Busy Java Developers Guide to NoSQL | Ted NewardJAX London
 
Terms of endearment - the ElasticSearch Query DSL explained
Terms of endearment - the ElasticSearch Query DSL explainedTerms of endearment - the ElasticSearch Query DSL explained
Terms of endearment - the ElasticSearch Query DSL explainedclintongormley
 
Javascript Primer
Javascript PrimerJavascript Primer
Javascript PrimerAdam Hepton
 
Why Python Web Frameworks Are Changing the Web
Why Python Web Frameworks Are Changing the WebWhy Python Web Frameworks Are Changing the Web
Why Python Web Frameworks Are Changing the Webjoelburton
 
Micro-ORM Introduction - Don't overcomplicate
Micro-ORM Introduction - Don't overcomplicateMicro-ORM Introduction - Don't overcomplicate
Micro-ORM Introduction - Don't overcomplicateKiev ALT.NET
 
Modelagem de Dados Semiestruturados com ISIS-DM
Modelagem de Dados Semiestruturados com ISIS-DMModelagem de Dados Semiestruturados com ISIS-DM
Modelagem de Dados Semiestruturados com ISIS-DMGustavo Fonseca
 
Zend framework 05 - ajax, json and j query
Zend framework 05 - ajax, json and j queryZend framework 05 - ajax, json and j query
Zend framework 05 - ajax, json and j queryTricode (part of Dept)
 
The bones of a nice Python script
The bones of a nice Python scriptThe bones of a nice Python script
The bones of a nice Python scriptsaniac
 

Semelhante a Mongokit presentation mongofr-2010 (20)

Sencha Touch Intro
Sencha Touch IntroSencha Touch Intro
Sencha Touch Intro
 
Python - Getting to the Essence - Points.com - Dave Park
Python - Getting to the Essence - Points.com - Dave ParkPython - Getting to the Essence - Points.com - Dave Park
Python - Getting to the Essence - Points.com - Dave Park
 
External Data Access with jQuery
External Data Access with jQueryExternal Data Access with jQuery
External Data Access with jQuery
 
Javascript2839
Javascript2839Javascript2839
Javascript2839
 
Json
JsonJson
Json
 
Rapid and Scalable Development with MongoDB, PyMongo, and Ming
Rapid and Scalable Development with MongoDB, PyMongo, and MingRapid and Scalable Development with MongoDB, PyMongo, and Ming
Rapid and Scalable Development with MongoDB, PyMongo, and Ming
 
JavaScript Needn't Hurt!
JavaScript Needn't Hurt!JavaScript Needn't Hurt!
JavaScript Needn't Hurt!
 
Python and MongoDB
Python and MongoDBPython and MongoDB
Python and MongoDB
 
Integrate CI/CD Pipelines with Jira Software Cloud
Integrate CI/CD Pipelines with Jira Software CloudIntegrate CI/CD Pipelines with Jira Software Cloud
Integrate CI/CD Pipelines with Jira Software Cloud
 
Plone For Developers - World Plone Day, 2009
Plone For Developers - World Plone Day, 2009Plone For Developers - World Plone Day, 2009
Plone For Developers - World Plone Day, 2009
 
JQuery Basics
JQuery BasicsJQuery Basics
JQuery Basics
 
Architecture | Busy Java Developers Guide to NoSQL | Ted Neward
Architecture | Busy Java Developers Guide to NoSQL | Ted NewardArchitecture | Busy Java Developers Guide to NoSQL | Ted Neward
Architecture | Busy Java Developers Guide to NoSQL | Ted Neward
 
Terms of endearment - the ElasticSearch Query DSL explained
Terms of endearment - the ElasticSearch Query DSL explainedTerms of endearment - the ElasticSearch Query DSL explained
Terms of endearment - the ElasticSearch Query DSL explained
 
Javascript Primer
Javascript PrimerJavascript Primer
Javascript Primer
 
C to perl binding
C to perl bindingC to perl binding
C to perl binding
 
Why Python Web Frameworks Are Changing the Web
Why Python Web Frameworks Are Changing the WebWhy Python Web Frameworks Are Changing the Web
Why Python Web Frameworks Are Changing the Web
 
Micro-ORM Introduction - Don't overcomplicate
Micro-ORM Introduction - Don't overcomplicateMicro-ORM Introduction - Don't overcomplicate
Micro-ORM Introduction - Don't overcomplicate
 
Modelagem de Dados Semiestruturados com ISIS-DM
Modelagem de Dados Semiestruturados com ISIS-DMModelagem de Dados Semiestruturados com ISIS-DM
Modelagem de Dados Semiestruturados com ISIS-DM
 
Zend framework 05 - ajax, json and j query
Zend framework 05 - ajax, json and j queryZend framework 05 - ajax, json and j query
Zend framework 05 - ajax, json and j query
 
The bones of a nice Python script
The bones of a nice Python scriptThe bones of a nice Python script
The bones of a nice Python script
 

Último

Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfOverkill Security
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
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 TerraformAndrey Devyatkin
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
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...Martijn de Jong
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
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, Adobeapidays
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 

Último (20)

Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
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
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
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...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
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
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 

Mongokit presentation mongofr-2010

  • 1. Enjoy your development Nicolas CLAIRON http://twitter.com/namlook #mongofr
  • 3.  
  • 4.  
  • 5. A python ODM for MongoDB
  • 7. Underlying philosophy light and powerful simple fast
  • 9. class MyDocument (Document) : Structure Options Descriptors
  • 10. class MyDocument (Document) : structure = { 'foo' : int , 'bar' : float , 'spam' :{ 'eggs' : [ unicode ], 'blah' : None , } } Options Descriptors
  • 11. class MyVeryNestedDoc (Document): structure = { '1' :{ '2' :{ '3' :{ '4' :{ '5' :{ '6' :{ '7' : int , '8' :{ '9' : float , } } } } } } } }
  • 12. class MyDocument (Document) : structure = { 'foo' : unicode , 'bar' : int , 'spam' :{ 'eggs' : [ unicode ], 'blah' : float , } } Options Descriptors
  • 13. class MyDocument (Document) : structure = { 'foo' : unicode , 'bar' : int , 'spam' :{ 'eggs' : [ unicode ], 'blah' : float , } } required = [ 'foo' , 'spam.eggs' ] default_values = { 'spam.blah'  : 1.0} validators = { 'bar' : lambda x >0} Options
  • 14. class MyDocument (Document) : structure = { 'foo' : unicode , 'bar' : int , 'spam' :{ 'eggs' : [ unicode ], 'blah' : float , } } required = [ 'foo' , 'spam.eggs' ] default_values = { 'spam.blah'  : 1.0} validators = { 'bar' : lambda x >0} use_dot_notation = True skip_validation = True
  • 15.
  • 17. Pure python types
  • 18. Nested and complex schema declaration
  • 19. Fast  : don't instanciate objects
  • 20. Live update via instrospection
  • 22. Dynamic keys class MobilePhones (Document) : structure = { 'os'  : { unicode :[{ 'version' : float , 'name' : unicode }], } { 'os'  : { 'android' :[ { 'version' : 2.2 , 'name'  : 'froyo' }, { 'version' : 2.1 , 'name'  : 'eclair' } ], 'iphone' :[{ 'version' : 4 , 'name'  : 'iOS' }], }
  • 23. It's all about Pymongo
  • 24.
  • 25. Use the same syntax
  • 26.
  • 27.
  • 29. One syntax to rule them all
  • 30. >>> from mongokit import * >>> con = Connection()
  • 31. >>> from mongokit import * >>> con = Connection() Pymongo's way >>> doc = con.mydb.mycol.find_one() # very fast ! # doc is a dict instance
  • 32. >>> from mongokit import * >>> con = Connection() Pymongo's way >>> doc = con.mydb.mycol.find_one() # very fast ! # doc is a dict instance Mongokit's way >>> doc = con.mydb.mycol.MyDocument.find_one() # doc is a MyDocument instance >>> doc.spam.eggs.append(u'foo') >>> doc.save()
  • 34. Inheriance / Polymorphism class A (Document) : structure = { 'a' : { 'foo'  : unicode , } } class B (Document) : structure = { 'b' : { 'bar'  : [ float ] , } }
  • 35. Inheriance / Polymorphism class A (Document) : structure = { 'a' : { 'foo'  : unicode , } } class B (Document) : structure = { 'b' : { 'bar'  : [ float ] , } } class C (A,B) : structure = { 'c' : { 'spam'  : int , } }
  • 36. Inheriance / Polymorphism class A (Document) : structure = { 'a' : { 'foo'  : unicode , } } class B (Document) : structure = { 'b' : { 'bar'  : [ float ] , } } class C (A,B) : structure = { 'c' : { 'spam'  : int , } } { 'a'  : { 'foo'  : None }, 'b'  : { 'bar'  : [] }, 'c'  : { 'spam'  : None } } >>> con.mydb.mycol.C()
  • 37. Dot notation class MyDocument (Document) : structure = { 'foo' : unicode , 'bar' : int , 'spam' :{ 'eggs' : [ unicode ], 'blah' : float , } }
  • 38. Dot notation class MyDocument (Document) : structure = { 'foo' : unicode , 'bar' : int , 'spam' :{ 'eggs' : [ unicode ], 'blah' : float , } } use_dot_notation = True
  • 39. Dot notation class MyDocument (Document) : structure = { 'foo' : unicode , 'bar' : int , 'spam' :{ 'eggs' : [ unicode ], 'blah' : float , } } use_dot_notation = True >>> doc = con.mydb.mycol.MyDocument() >>> doc.foo = u'the foo' >>> doc.spam.eggs.append(u'bla', u'toto')
  • 40. Document reference class Comment (Document) : structure = { 'title' : unicode 'body' : unicode , 'author'  : ObjectId, } class User (Document) : structure = { 'login' : unicode , 'name' : unicode , }
  • 41. Document reference class Comment (Document) : structure = { 'title' : unicode 'body' : unicode , 'author'  : User , } use_autorefs = True class User (Document) : structure = { 'login' : unicode , 'name' : unicode , }
  • 42. Document reference class Comment (Document) : structure = { 'title' : unicode 'body' : unicode , 'author'  : User, } use_autorefs = True class User (Document) : structure = { 'login' : unicode , 'name' : unicode , } { 'title' : 'Hello world !', 'body' : 'My first blog post', 'author' : DBRef(...), } >>> con.mydb.mycol.find_one()
  • 43. Document reference class Comment (Document) : structure = { 'title' : unicode 'body' : unicode , 'author'  : User, } use_autorefs = True class User (Document) : structure = { 'login' : unicode , 'name' : unicode , } { 'title' : 'Hello world !', 'body' : 'My first blog post', 'author' : DBRef(...), } >>> con.mydb.mycol.find_one() { 'title' : 'Hello world !', 'body' : 'My first blog post', 'author' : { 'login' : 'timy', 'name' : 'Timy Donzy' } } >>> con.mydb.mycol.BlogPost.find_one()
  • 44. GridFS support class MyDocument (Document) : structure = { 'foo' : unicode , 'bar' : int , } grid_fs = { 'files' :[ 'source' , 'template' ], 'containers' : [ 'images' ], } >>> doc = con.mydb.mycol.MyDocument() >>> doc.fs.source = '...' >>> doc.fs.images['image1.png'] = '…'
  • 45. i18n class MyDocument (Document) : structure = { 'foo' : unicode , 'bar' : int , } i18n = [ 'foo' ] use_dot_notation = True >>> doc = con.mydb.mycol.MyDocument() >>> doc.set_lang('fr') >>> doc.foo = u'Salut' >>> doc.set_lang('en') >>> doc.foo = u'Hello' >>> doc.save()
  • 46.
  • 51.
  • 58.
  • 64. Json export/import CAN BE DISABLED
  • 66.
  • 73.
  • 77. Restructured and improved documentation
  • 78. A new logo ! v1.0
  • 79. a social trading startup MongoKit in production
  • 81. Thanks you ! Questions ? Suggestions ? Comments ? Insults* ? * just kidding