The first section of the update command you make is essentially what you want from the "compliesToSomeRule" method. For example, lets say that compliesToSomeRule is defined as follows:
def compliesToSomeResult(doc):
if doc['a'] == 0:
return True
else:
return False
Then you could skip this set and just do
myDB.update({ 'a' : 0 }, {'$set' : { 'x' : 'y' }})
This will then apply your update document (the second one) to all documents in your collection that have a field a equal to 0.
Another example: if you want to find all documents where 'a' > 0 you could do
myDB.update({ 'a' : { '$gt' : 0 }}, {'$set' : {'x' : 'y'}})
The first section of the update call, the "query" section, is how you specify the which documents receive the update. The second section defines what the update actually is.
Here is a document that you might find helpful while reviewing this material: http://docs.mongodb.org/manual/applications/update/