The Major Release of Motor 2.0
The Major Release of Motor 2.0
To support multi-document transactions, I had to make breaking changes to Motor’s session API and release a major version bump, Motor 2.0.
Join the DZone community and get the full member experience.Join For Free
Compliant Database DevOps and the role of DevSecOps DevOps is becoming the new normal in application development, and DevSecOps is now entering the picture. By balancing the desire to release code faster with the need for the same code to be secure, it addresses increasing demands for data privacy. But what about the database? How can databases be included in both DevOps and DevSecOps? What additional measures should be considered to achieve truly compliant database DevOps? This whitepaper provides a valuable insight. Get the whitepaper
To support multi-document transactions, I had to make breaking changes to Motor’s session API and release a major version bump, Motor 2.0. Since this is a major release, I also deleted many helper methods and APIs that had been deprecated over time since Motor 1.0, most notably the old CRUD methods
save, and the original callback-based API. Read the Motor 2.0 Migration Guide carefully to upgrade your existing Motor application. Motor 2.0 also includes a Python 3.7 compatibility fix in the MotorChangeStream class returned by MotorCollection.watch.
Motor 2.0’s changes have a big impact for some applications, so I created a bridge release that raises DeprecationWarning for all the APIs that are deleted in Motor 2.0, especially the callback API, which hasn’t been deprecated before. Those DeprecationWarnings plus the Python 3.7 compatibility fix constitute Motor 1.3.0.
For applications that only need Python 3.7 compatibility, I’ve created Motor 1.2.4, which includes the Python 3.7 fix and no other changes.
Detailed release notes follow.
Motor 2.0 drops support for MongoDB 2.6 and adds support for MongoDB 4.0 features including multi-document transactions and change stream notifications on entire databases or entire MongoDB servers. This version of Motor requires PyMongo 3.7 or later.
There is added support for aiohttp 3.0 and later, and older aiohttp versions were dropped. The aiohttp integration now requires Python 3.5+.
This is a major release that removes previously deprecated APIs.
The MotorDatabase.add_user and MotorDatabase.remove_user methods are deleted. Manage user accounts with four database commands: createUser, usersInfo, updateUser, and dropUser. You can run any database command with the MotorDatabase.command() method.
- New methods for retrieving batches of raw BSON:
- Motor adds its name, version, and Tornado’s version (if appropriate) to the client data logged by the MongoDB server when Motor connects in addition to the data added by PyMongo.
- Calling batch_size() on a cursor returned from aggregate() no longer raises AttributeError.
Deprecate Motor’s old callback-based async API in preparation for removing it in Motor 2.0. Raise DeprecationWarning whenever a callback is passed.
If you find issues, file a bug, and I’ll respond promptly. If it works for you, don’t be silent! Tweet me and tell me!
Published at DZone with permission of A. Jesse Jiryu Davis , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.