<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def patch(self, request, format=None):
 """ Update an existing Channel """

        data = request.data.copy()

        # Get chat type record
        try:
            ct = ChatType.objects.get(id=data.pop("chat_type"))
            data["chat_type"] = ct
        except ChatType.DoesNotExist:
            return typeNotFound404

        if not self.is_path_unique(
            data["id"], data["publish_path"], ct.publish_path
        ):
            return notUnique400

        # Get channel record
        try:
            c = Channel.objects.get(id=data.pop("id"))
        except Channel.DoesNotExist:
            return channelNotFound404

        # Save new data
        for key, value in data.items():
            setattr(c, key, value)
        c.save()

        self.handle_webhook(c)

        return Response(
            {
                "text": "Channel saved.",
                "method": "PATCH",
                "saved": ChannelCMSSerializer(c).data,
            },
            200,
        )