Skip to main content
Info:

See the mongo site for more information. See github for the latest source.

Author:

Alexander Artemenko <svetlyak.40wt@gmail.com>

About

The PyMongoBongo distribution contains wrappers to add some syntax sugar to PyMongo for easier interaction with the Mongo database using “python way”.

ChangeLog

0.1.3

  • Fixed __len__ method, broken by changes in pymongo 1.1.1. Now mongobongo depends on pymongo >= 1.1.1.

0.1.2

  • Fixed ordering in case, when ‘find_one’ is used.

  • Fixed default cursor ordering, now it is applied in the constructor.

0.1.1

  • Added automatic DBRef usage, when one document contains another. Here is an example:

    >>> author = Author(name = 'Alexander')
    >>> article =  Article(title = 'Life is miracle', author = author)
    >>> Author.objects.count()
    0
    >>> article.save()
    >>> article = Article.objects.find_one()
    >>> article.author.name
    'Alexander'
    >>> Author.objects.count()
    1

0.1.0

  • Basic support for documents with attributes.

Installation

If you have setuptools installed you should be able to do easy_install pymongo-bongo to install PyMongoBongo. Otherwise you can download the project source and do python setup.py install to install.

Dependencies

The PyMongoBongo depends on PyMongo >= 1.1.1

Additional dependencies are:

  • (to generate documentation) epydoc

  • (to auto-discover tests) nose

Examples

Here’s a basic example:

>>> from pymongo.connection import Connection
>>> from mongobongo import Document
>>> class Article(Document):
...     collection = 'articles'
...     def get_full_title(self):
...         return '%s (%s)' % (self.title, ', '.join(self.tags))
>>> connection = Connection("localhost", 27017)
>>> Article.objects.db = connection.test
>>> article = Article(author = 'Alex', title = 'Pink Pony\'s Life', tags = ['mongo', 'bongo'])
>>> article.save()
>>> articles = Article.objects.all()
>>> len(articles)
1
>>> article = Article(author = 'Alex', title = 'Long Long Python', tags = ['python', 'devel'], subtitle = 'Not such long')
>>> article.save()
>>> articles = Article.objects.all()
>>> len(articles)
2
>>> python_articles = Article.objects.find({'tags': 'python'})
>>> len(python_articles)
1
>>> python_articles[0].title
'Long Long Python'

Documentation

You will need epydoc installed to generate the documentation. Documentation can be generated by running python setup.py doc. Generated documentation can be found in the doc/ directory.

Testing

The easiest way to run the tests is to install nose (easy_install nose) and run nosetests or python setup.py test in the root of the distribution. Tests are located in the test/ directory.

Credits

  • Slava Vishnyakov, for ‘Document.remove’ method.

Wanna be listed here? Go to the GitHub, fork the project and send me patches :)

Metadata

Release files for pymongo-bongo 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pymongo-bongo 0.1.3
File Size Uploaded
pymongo-bongo-0.1.3.tar.gz 12.1 kB Details

Release files / pymongo-bongo-0.1.3.tar.gz

Download URL pymongo-bongo-0.1.3.tar.gz
Size 12.1 kB
Tags Source
SHA-256 checksum
How to use checksums
e52687fa4140393b7f99d1c0ce81561c5ef98260140c227e320d4406d6c71fe3
BLAKE2b-256 checksum
How to use checksums
33fe479b2085406a3d529318871eee1a34141c1cbcd16ca0a387c748caf4d9fa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.3 This release

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page