@classmethod
def _login_event_handler(cls, user=None):
    """This method is triggered when a login event occurs.

        When a user logs in, all items in his guest cart should be added to his
        logged in or registered cart. If there is no such cart, it should be
        created.
        """
    guest_cart = cls.find_cart(None)
    if not guest_cart:
        return
    if guest_cart.sale and guest_cart.sale.lines:
        to_cart = cls.open_cart(True)
        for from_line in guest_cart.sale.lines:
            sale_line = from_line.add_to(to_cart.sale)
            sale_line.save()
    guest_cart._clear_cart()
