SlideShare ist ein Scribd-Unternehmen logo
1 von 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'] = '…'

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Kürzlich hochgeladen

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
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
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
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
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 

Kürzlich hochgeladen (20)

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
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...
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
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
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 

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