def update(self):
self.item_count = self.count_items()<EOL>self.total_price = self.count_total_price()<EOL>session = self.request.session<EOL>session_items = {}<EOL>for pk, item in self.items.items():<EOL><INDENT>session_items[pk] = dict(quantity=item.quantity, **item._kwargs)<EOL><DEDENT>session_data = session[session_key]<EOL>session_data['<STR_LIT>'] = session_items<EOL>session_data['<STR_LIT>'] = self.item_count<EOL>session_data['<STR_LIT>'] = str(self.total_price)<EOL>session.modified = True<EOL>
Update the cart.

        First this method updates attributes dependent on the cart's
        `items`, such as `total_price` or `item_count`.
        After that, it saves the new cart state to the session.

        Generally, you'll need to call this method by yourself, only
        when implementing new methods that directly change the `items`
        attribute.