SlideShare a Scribd company logo
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'] = '…'

More Related Content

What's hot

06. ElasticSearch : Mapping and Analysis
06. ElasticSearch : Mapping and Analysis06. ElasticSearch : Mapping and Analysis
06. ElasticSearch : Mapping and Analysis
OpenThink 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 Library
Dave Ross
 
Ods Markup And Tagsets: A Tutorial
Ods Markup And Tagsets: A TutorialOds Markup And Tagsets: A Tutorial
Ods Markup And Tagsets: A Tutorial
simienc
 
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
 
Lettering js
Lettering jsLettering js
Lettering js
davatron5000
 
Mongo learning series
Mongo learning series Mongo learning series
Mongo learning series
Prashanth Panduranga
 

What's hot (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
 

Similar to 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 Park
pointstechgeeks
 
External Data Access with jQuery
External Data Access with jQueryExternal Data Access with jQuery
External Data Access with jQueryDoncho Minkov
 
Json
JsonJson
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
Rick Copeland
 
JavaScript Needn't Hurt!
JavaScript Needn't Hurt!JavaScript Needn't Hurt!
JavaScript Needn't Hurt!
Thomas Kjeldahl Nilsson
 
Python and MongoDB
Python and MongoDBPython and MongoDB
Python and MongoDB
Christiano Anderson
 
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
Atlassian
 
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
Core Software Group
 
JQuery Basics
JQuery BasicsJQuery Basics
JQuery Basics
Alin Taranu
 
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
JAX 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 explained
clintongormley
 
Javascript Primer
Javascript PrimerJavascript Primer
Javascript Primer
Adam Hepton
 
C to perl binding
C to perl bindingC to perl binding
C to perl binding
Shmuel Fomberg
 
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
joelburton
 
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-DM
Gustavo 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 query
Tricode (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 script
saniac
 

Similar to 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
 
Json
JsonJson
Json
 
Javascript2839
Javascript2839Javascript2839
Javascript2839
 
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
 

Recently uploaded

Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
Vlad Stirbu
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
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
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 

Recently uploaded (20)

Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
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 !
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 

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