Your SlideShare is downloading. ×
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Mongokit presentation mongofr-2010

3,176

Published on

Slides of my presentation of MongoKIT at MongoFR 2010.

Slides of my presentation of MongoKIT at MongoFR 2010.

Published in: Technology, News & Politics
1 Comment
6 Likes
Statistics
Notes
No Downloads
Views
Total Views
3,176
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
35
Comments
1
Likes
6
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Enjoy your development Nicolas CLAIRON http://twitter.com/namlook #mongofr
  • 2. Introducing...
  • 3.  
  • 4.  
  • 5. A python ODM for MongoDB
  • 6. Underlying philosophy
  • 7. Underlying philosophy light and powerful simple fast
  • 8. Document class structure
  • 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. Advantages
    • Great readability
    • 16. Simple python dict
    • 17. Pure python types
    • 18. Nested and complex schema declaration
    • 19. Fast  : don't instanciate objects
    • 20. Live update via instrospection
    • 21. Dynamic keys
  • 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.
    • Built on top of Pymongo
    • 25. Use the same syntax
  • 26.
    • Built on top of Pymongo
    • 27. Use the same syntax
    • Easy code migration (pymongo -> MongoKit)
    • 28. Learn fast
    • 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()
  • 33. Features
  • 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.
    • Inheritance / Polymorphism
    • 47. Dot notation
    • 48. Document auto-reference support (DBRef)
    • 49. GridFS
    • 50. I18n support
  • 51.
    • Inheritance / Polymorphism
    • 52. Dot notation
    • 53. Document auto-reference support (DBRef)
    • 54. GridFS
    • 55. I18n support
    • 56. Schema migration
    • 57. Json export/import
  • 58.
    • Inheritance / Polymorphism
    • 59. Dot notation
    • 60. Document auto-reference support (DBRef)
    • 61. GridFS
    • 62. I18n support
    • 63. Schema migration
    • 64. Json export/import
    CAN BE DISABLED
  • 65. Roadmap and futur plans
  • 66. Features planed
  • 73.
    • All features implemented
    • 74. Optimizations
    • 75. Stabilized API
    • 76. Tested, tested, tested...
    • 77. Restructured and improved documentation
    • 78. A new logo !
    v1.0
  • 79. a social trading startup MongoKit in production
  • 80. Thanks you !
  • 81. Thanks you ! Questions ? Suggestions ? Comments ? Insults* ? * just kidding

×