[Mailman-Developers] Problem passing parameters to the REST API

khushboo surana khushboo9293 at gmail.com
Sun Jun 14 11:57:05 CEST 2015


Hello!!

First of all I am sorry I did not not provide a lot of information
(especially the diffs) in my previous mail that was required to get to the
root of the problem. However, with the information Barry provided, I was
able to make a few corrections to my code and now I am able to pass the
mode of unsubscription as a parameter to the REST through the HTTP DELETE
request.


On Fri, Jun 12, 2015 at 11:48 PM, Barry Warsaw <barry at list.org> wrote:

> I'd like to see the diff, or the modified function.

 Although it may not be required now, I am adding the link to my changes
below. In case you need to see it to give further suggestions.

Mailman Core:
https://github.com/khushboo9293/mailman/commit/d3e7b10da3f05357b6436ce2d9938bfb361a54d6

Mailman Client:
https://github.com/khushboo9293/mailman.client/commit/83397557f693f10b4a3f4d93bfb5be5c2412113d

> Be sure you don't change the signature of the on_delete() method.  That
must
> take exactly three arguments: self, request, and response.  Normally, the
way
> on_patch() or on_post() dig parameters out of the data is through a
> Validator() instance, which lists the parameters and their type conversion
> methods.

I hadn't changed the signature of the on_delete() method the method took 3
arguments only.Instead, I tried to pass the parameters in the body of
DELETE request and used validator() to extract the data. But after cross
checking with other examples in REST modules, I found a mistake in the way
I was using validator and rectified it.

> But on_delete() (really the HTTP DELETE method) doesn't accept any
arguments
> since its purpose is to delete a resource.
>
> I'm not sure what your best option is for recording the "mode" of the
> deletion.  I'm not sure whether it's technically acceptable to add data
to a
> DELETE method (the documentation and books I've consulted don't say either
> way).

As per what I had read, its is not forbidden to send data through a DELETE
request but in many cases it is rejected or ignored by the server. In my
case however, I am able to retrieve the data in the on_delete() method here
and pass it to the model method unsubscribe().
Link to rest/members.py

> Even if it were acceptable, I think this on_delete() method would at least
> have to accept and do something reasonable with zero arguments (i.e. the
mode
> would be optional).

I have made changes in the REST code (rest/members.py) to make the mode
optional. If the mode is not provided in the parameters, then the default
mode would be assigned. Currently I don't know what the default mode of
unsubsciption is, hence provided an arbitrary string.


Regards
Khushboo


More information about the Mailman-Developers mailing list