Merge lp:~ltrager/maas/delete_on_files into lp:~maas-committers/maas/trunk
Proposed by
Lee Trager
Status: | Merged |
---|---|
Approved by: | Lee Trager |
Approved revision: | no longer in the source branch. |
Merged at revision: | 4951 |
Proposed branch: | lp:~ltrager/maas/delete_on_files |
Merge into: | lp:~maas-committers/maas/trunk |
Diff against target: |
181 lines (+58/-21) 6 files modified
src/maascli/api.py (+1/-1) src/maascli/tests/test_api.py (+6/-6) src/maasserver/api/files.py (+17/-2) src/maasserver/api/support.py (+8/-6) src/maasserver/api/tests/test_filestorage.py (+12/-0) src/maastesting/djangoclient.py (+14/-6) |
To merge this branch: | bzr merge lp:~ltrager/maas/delete_on_files |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Gavin Panella (community) | Approve | ||
Review via email: mp+292455@code.launchpad.net |
Commit message
Allow deleting a file by specifying the filename as a parameter
Description of the change
MAAS currently has the ability to get files on the files handle by calling the get operation and specifying the filename as a parameter. This allows users to get files with a leading /. The main concern in lp:1566108 is how to delete them. This adds the ability to call the delete operation on files specifying the filename as a parameter.
I had to make this call a POST operation as piston only processes form data on GET and POST. See the link below for a summary on why
http://
To post a comment you must log in.
> I had to make this call a POST operation as piston only processes form
> data on GET and POST.
Django is deceiving us.
First, Django does parse the query string for all HTTP methods, but it
makes it sound like it doesn't because it puts the result into
request.GET.
Second, the Django test client assumes that you only ever put form data
into the request body OR the query string, not both. For GET it assumes
that form data goes in the query string, and for PUT, POST, and DELETE
it assumes that all form data goes into the request body. When using the
test client we don't see that this is happening.
Now, the URL http:// example. com/?foo= 123 refers to a resource in the example. com/bar/ 789 refers to a resource — that is,
same way that http://
the _whole URL_ is a reference to a thing, not just the bit before the
query string.
But Django leads us to imagine that `GET foo?bar=123` is akin to a
function call to the resource foo with the argument bar=123, but what
we've actually got is a reference — foo?bar=123 — to a resource.
The *implementation* may route to a function according to the path
before the query string, and then pass parameters from the query into
the function, but at the HTTP level it's just a reference, an address to
a resource.
Anyway, merge lp:~allenap/maas/delete_on_files and you'll find that I've .../files/ ?filename= foo/bar` works.
added an extra fix-up to the Django test client and adjusted the code so
that `DELETE http://
I've also tightened up the rules on method naming so that `POST
...?op=delete` will not longer be permitted; I noticed that both
FileHandler.delete and FilesHandler.delete worked via both `POST
path?op=delete` AND `DELETE path`.