<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -16,6 +16,7 @@
 
 import types
 import warnings
+import struct
 
 import pymongo
 import bson
@@ -26,7 +27,6 @@ from errors import InvalidName, OperationFailure
 from code import Code
 
 _ZERO = &quot;\x00\x00\x00\x00&quot;
-_ONE = &quot;\x01\x00\x00\x00&quot;
 
 
 class Collection(object):
@@ -196,7 +196,7 @@ class Collection(object):
         return len(ids) == 1 and ids[0] or ids
 
     def update(self, spec, document,
-               upsert=False, manipulate=False, safe=False):
+               upsert=False, manipulate=False, safe=False, multi=False):
         &quot;&quot;&quot;Update a single document in this collection.
 
         Raises TypeError if either spec or document isn't an instance of
@@ -210,10 +210,16 @@ class Collection(object):
             a document to be updated
           - `document`: a SON object specifying the document to be used for the
             update or (in the case of an upsert) insert. For more information
-            on update syntax / modifiers see the MongoDB wiki_.
+            on update syntax / modifiers see the MongoDB wiki_
           - `upsert` (optional): perform an upsert operation
           - `manipulate` (optional): manipulate the document before updating?
           - `safe` (optional): check that the update succeeded?
+          - `multi` (optional): update all documents that match `spec`, rather
+            than just the first matching document. The default value for
+            `multi` is currently False, but this might eventually change to
+            True. It is recommended that you specify this argument explicitly
+            for all update operations in order to prepare your code for that
+            change.
 
         .. _wiki: http://www.mongodb.org/display/DOCS/Updating
         &quot;&quot;&quot;
@@ -227,7 +233,13 @@ class Collection(object):
         if upsert and manipulate:
             document = self.__database._fix_incoming(document, self)
 
-        message = upsert and _ONE or _ZERO
+        options = 0
+        if upsert:
+            options += 1
+        if multi:
+            options += 2
+
+        message = struct.pack(&quot;&lt;i&quot;, options)
         message += bson.BSON.from_dict(spec)
         message += bson.BSON.from_dict(document)
 </diff>
      <filename>pymongo/collection.py</filename>
    </modified>
    <modified>
      <diff>@@ -20,6 +20,8 @@ import time
 import sys
 sys.path[0:0] = [&quot;&quot;]
 
+from nose.plugins.skip import SkipTest
+
 import qcheck
 from test_connection import get_connection
 import version
@@ -489,6 +491,23 @@ class TestCollection(unittest.TestCase):
         self.assertEqual(db.test.find_one(id1)[&quot;x&quot;], 7)
         self.assertEqual(db.test.find_one(id2)[&quot;x&quot;], 1)
 
+    def test_multi_update(self):
+        db = self.db
+        if not version.at_least(db.connection(), (1, 1, 3, -1)):
+            raise SkipTest()
+
+        db.drop_collection(&quot;test&quot;)
+
+        db.test.save({&quot;x&quot;: 4, &quot;y&quot;: 3})
+        db.test.save({&quot;x&quot;: 5, &quot;y&quot;: 5})
+        db.test.save({&quot;x&quot;: 4, &quot;y&quot;: 4})
+
+        db.test.update({&quot;x&quot;: 4}, {&quot;$set&quot;: {&quot;y&quot;: 5}}, multi=True)
+
+        self.assertEqual(3, db.test.count())
+        for doc in db.test.find():
+            self.assertEqual(5, doc[&quot;y&quot;])
+
     def test_upsert(self):
         db = self.db
         db.drop_collection(&quot;test&quot;)</diff>
      <filename>test/test_collection.py</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>39774f4f149e03ab4fdd2aec254ed50317b7d7ca</id>
    </parent>
  </parents>
  <author>
    <name>Mike Dirolf</name>
    <email>mike@10gen.com</email>
  </author>
  <url>http://github.com/mongodb/mongo-python-driver/commit/8e835e26851b4348e9ab94bcc045a9b9ff488bea</url>
  <id>8e835e26851b4348e9ab94bcc045a9b9ff488bea</id>
  <committed-date>2009-10-26T07:45:05-07:00</committed-date>
  <authored-date>2009-10-26T07:45:05-07:00</authored-date>
  <message>add support for multi-update: update(..., multi=True)</message>
  <tree>55c841b499c8d6e66b1d6348abade762fdd0df98</tree>
  <committer>
    <name>Mike Dirolf</name>
    <email>mike@10gen.com</email>
  </committer>
</commit>
