Hi all, I'm using Pylons-0.9.5-py2.5.
I've been trying to send a file to an update action with a
restcontroller (setup with map.resource). However it fails with the error :
<type 'exceptions.NotImplementedError'>: Action 1 is not implemented
I've created a restcontroller with the command 'paster restcontroller'.
The form is generated with the following command :
h.form(h.url_for('message', id=1), method='put', multipart=True)
The complete template is:
<% h.form(h.url_for('message'), method='put', multipart=True)%>
<% h.file_field('file') %>
<% h.submit("Create file") %>
<% h.end_form() %>
<% h.form(h.url_for('message', id=1), method='put', multipart=True)%>
<% h.file_field('file') %>
<% h.submit("Send file") %>
<% h.end_form() %>
<% h.form(h.url_for('message', id=1), method='put')%>
<% h.file_field('file') %>
<% h.submit("Send file 2") %>
<% h.end_form() %>
The relevant code in the controller is :
def create(self):
"""POST /: Create a new item."""
# url_for('messages')
return Response(request.POST['file'].filename)
def update(self, id):
"""PUT /id: Update an existing item."""
# Forms posted to this method should contain a
# hidden field:
# <input type="hidden" name="_method" value="PUT" />
# Or using helpers:
# h.form(h.url_for('message', id=ID), method='put')
# url_for('message', id=ID)
return Response(request.POST['file'].filename)
When the button "Create file" is clicked, the name of the filename is
returned, which is the expected behavior.
When the button "Send file" is clicked, the server generates the error:
<type 'exceptions.NotImplementedError'>: Action 1 is not implemented
The expected result is the same as above.
When the button "Send file2" is clicked, the server generates the error:
<type 'exceptions.AttributeError'>: 'str' object has no attribute 'filename'
That is the expected result since multipart is not used.
I've attached a complete test application. You can uncompress the tar file
and run it with "paster serve --reload development.ini" to reproduce the
problem.
Is it a problem with pylons or have I missed something with uploading
files to a restcontroller update method ?
Thank you,
--
Mathias
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---
mytest.tgz
Description: GNU Unix tar archive
