#NEWLINE# def update( self , **values ) : #NEWLINE# #INDENT# '\n        Performs an update on the row selected by the queryset. Include values to update in the\n        update like so:\n\n        .. code-block:: python\n\n            Model.objects(key=n).update(value=\'x\')\n\n        Passing in updates for columns which are not part of the model will raise a ValidationError.\n\n        Per column validation will be performed, but instance level validation will not\n        (i.e., `Model.validate` is not called).  This is sometimes referred to as a blind update.\n\n        For example:\n\n        .. code-block:: python\n\n            class User(Model):\n                id = Integer(primary_key=True)\n                name = Text()\n\n            setup(["localhost"], "test")\n            sync_table(User)\n\n            u = User.create(id=1, name="jon")\n\n            User.objects(id=1).update(name="Steve")\n\n            # sets name to null\n            User.objects(id=1).update(name=None)\n\n\n        Also supported is blindly adding and removing elements from container columns,\n        without loading a model instance from Cassandra.\n\n        Using the syntax `.update(column_name={x, y, z})` will overwrite the contents of the container, like updating a\n        non container column. However, adding `__<operation>` to the end of the keyword arg, makes the update call add\n        or remove items from the collection, without overwriting then entire column.\n\n        Given the model below, here are the operations that can be performed on the different container columns:\n\n        .. code-block:: python\n\n            class Row(Model):\n                row_id      = columns.Integer(primary_key=True)\n                set_column  = columns.Set(Integer)\n                list_column = columns.List(Integer)\n                map_column  = columns.Map(Integer, Integer)\n\n        :class:`~cqlengine.columns.Set`\n\n        - `add`: adds the elements of the given set to the column\n        - `remove`: removes the elements of the given set to the column\n\n\n        .. code-block:: python\n\n            # add elements to a set\n            Row.objects(row_id=5).update(set_column__add={6})\n\n            # remove elements to a set\n            Row.objects(row_id=5).update(set_column__remove={4})\n\n        :class:`~cqlengine.columns.List`\n\n        - `append`: appends the elements of the given list to the end of the column\n        - `prepend`: prepends the elements of the given list to the beginning of the column\n\n        .. code-block:: python\n\n            # append items to a list\n            Row.objects(row_id=5).update(list_column__append=[6, 7])\n\n            # prepend items to a list\n            Row.objects(row_id=5).update(list_column__prepend=[1, 2])\n\n\n        :class:`~cqlengine.columns.Map`\n\n        - `update`: adds the given keys/values to the columns, creating new entries if they didn\'t exist, and overwriting old ones if they did\n\n        .. code-block:: python\n\n            # add items to a map\n            Row.objects(row_id=5).update(map_column__update={1: 2, 3: 4})\n        ' #NEWLINE# if ( not values ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# nulled_columns = set ( ) #NEWLINE# us = UpdateStatement ( self . column_family_name , where = self . _where , ttl = self . _ttl , timestamp = self . _timestamp , conditionals = self . _conditional , if_exists = self . _if_exists ) #NEWLINE# for ( name , val ) in values . items ( ) : #NEWLINE# #INDENT# ( col_name , col_op ) = self . _parse_filter_arg ( name ) #NEWLINE# col = self . model . _columns . get ( col_name ) #NEWLINE# if ( col is None ) : #NEWLINE# #INDENT# raise ValidationError ( '{0}.{1} has no column named: {2}' . format ( self . __module__ , self . model . __name__ , col_name ) ) #NEWLINE# #UNINDENT# if col . is_primary_key : #NEWLINE# #INDENT# raise ValidationError ( "Cannot apply update to primary key '{0}' for {1}.{2}" . format ( col_name , self . __module__ , self . model . __name__ ) ) #NEWLINE# #UNINDENT# val = col . validate ( val ) #NEWLINE# if ( val is None ) : #NEWLINE# #INDENT# nulled_columns . add ( col_name ) #NEWLINE# continue #NEWLINE# #UNINDENT# us . add_update ( col , val , operation = col_op ) #NEWLINE# #UNINDENT# if us . assignments : #NEWLINE# #INDENT# self . _execute ( us ) #NEWLINE# #UNINDENT# if nulled_columns : #NEWLINE# #INDENT# ds = DeleteStatement ( self . column_family_name , fields = nulled_columns , where = self . _where , conditionals = self . _conditional , if_exists = self . _if_exists ) #NEWLINE# self . _execute ( ds )