# file attachment while asking a question does not work

Does this feature expected to work? Instead of being uploaded, a text is appended to the question including the wrong local path to the file (for instance d:/fakepath/myfile.doc instead of d:/myfolder/myfile.doc).

edit retag close merge delete

Looks like whatever is shown in the local path depends on the system. On my machine the path (the directory part of it) is not shown at all, only the local file name. Maybe it is a good idea to normalize the local path to make sure the display is not showing drive letters and local directory structures.
( 2011-06-06 18:38:35 -0500 )edit

Sort by » oldest newest most voted

Thanks Evgeny. No problem for the technical detail. On my side, Askbot is set up on Redhat 5.5 with mysql and apache.

I have understood what happens.

First, the configuration for file extensions allowed is the same for images and attachments. I was expecting no limitation for attachments. I need to give the possibility to attach log files for instance, but it is not relevant for images. This is the case on askbot.org with doc files. Do you see a reason to limit file extensions for attachments, except the reuse of the function?

Second, there are minor bugs in the attachment pop-up :

1. if you choose OK without doing anything, it should do nothing, but instead the following text is appended : [file name]()

2. if you choose a file not allowed (in my example test.txt located in D:\tmp\test.txt on my machine), then you choose OK, the following text is appended : [C:\fakepath\test.txt]()

3. if you choose a file allowed (for instance askbot.gif), the file is uploaded, then you choose another file not allowed, the error message listing allowed extension does not appear, then you choose ok. The result is the following line appended : [C:\fakepath\askbot.gif](/en/upfiles/13069375968038733.gif).

more

I think that issues with the popup are fixed now, as for the reuse of the function - true, that's the reason, also the javascript is reused. As for making separate limitations extension for attachments and images - maybe makes sense, will look into this later.
( 2011-06-06 18:36:06 -0500 )edit
btw, very impressive testing :), thanks.
( 2011-06-06 18:36:38 -0500 )edit
The cases 1 and 2 are now fixed, but not the 3rd one. In a previous life I was managing a QA team in a software company ;-)
( 2011-06-07 04:03:14 -0500 )edit
I would just like to quickly modify the code to remove the limitations for file upload. I will have a look but maybe you know directly the answer. Is there a variable like ItemType (image or file) available in the request that I can use in the upload function?
( 2011-06-07 11:36:52 -0500 )edit

It should work, but maybe there is a bug when askbot is set up on windows.

Will you be able to debug it? I do not have a windows system here...

The upload function is upload in askbot/views/writers. What is the value of file_url variable in the end of the function?

The debugging can be done for example with pdb, - insert lines somewhere in the function:

import pdb
pdb.set_trace()


Then try to upload attachment, the debugger will pause in the shell and you'll be able to step through the instructions by typing "n" and to find what is the value of the variable - just type the variable name.

Sorry, going in detail, because I don't know if you are familiar with pdb.

Also, could you try checking which directory is used on your system to store uploaded files:

python manage.py shell
>>>from django.conf.import settings


It should print a path to a directory which must be writable by the server.

more