def add_resource(self, transaction, parent_resource, lp):
        """
        Render a POST on a new resource.

        :param request: the request
        :param response: the response
        :param parent_resource: the parent of the resource
        :param lp: the location_path attribute of the resource
        :return: the response
        """
        method = getattr(parent_resource, "render_POST", None)
        try:
            resource = method(request=transaction.request)
        except __HOLE__:
            transaction.response.code = defines.Codes.METHOD_NOT_ALLOWED.number
            return transaction
        if isinstance(resource, Resource):
            pass
        elif isinstance(resource, tuple) and len(resource) == 2:
            resource, callback = resource
            resource = self._handle_separate(transaction, callback)
            if not isinstance(resource, Resource):  # pragma: no cover
                transaction.response.code = defines.Codes.INTERNAL_SERVER_ERROR.number
                return transaction
        else:  # pragma: no cover
            # Handle error
            transaction.response.code = defines.Codes.INTERNAL_SERVER_ERROR.number
            return transaction

        resource.path = lp

        if resource.etag is not None:
            transaction.response.etag = resource.etag

        transaction.response.location_path = resource.path

        if resource.location_query is not None and len(resource.location_query) > 0:
            transaction.response.location_query = resource.location_query

        transaction.response.code = defines.Codes.CREATED.number
        transaction.response.payload = None
        resource.changed = True
        transaction.resource = resource

        self._parent.root[resource.path] = resource

        return transaction
dataset/ETHPy150Open Tanganelli/CoAPthon/coapthon/layers/resourcelayer.py/ResourceLayer.add_resource