Posted by Per Strandberg |
|
I have some unexpected behavior with attachments.
1 - uploaded twice If I attach a file to a snip the file ends up twice in my machine (once as "*.*" and then again as "*_.*"). Deleting the attachment via the web-interface only takes care of the file called *_.*, leaving the file with the nice filename in the filesystem. I looked at WikiAttachment.save and it seems very sane - do you have any idea where my strange behaviour is coming from, and why (perhaps it is the expected and desired modus operandi). I get the impression that the file is uploaded once as a file or something and then again as the proper attachment (?). Or am I missing something? 2 - url to attachments Also the links to attachments seem strange: the href I get is "var/sphene/sphwiki/attachment/..." whereas I would have expected MEDIA_ROOT + "var/sphene/sphwiki/attachment/..." since this is where it ends up in the machine. Again: am I just missing some setting? Thanks, /Per |
|
Posted by Per Strandberg |
|
I overrode and edited "macros/_attachments.html".
Thanks for your patience :) /P |
|
Posted by Per Strandberg |
|
But now I have the same problem with images so my spider sense is tingling. I think my problem is that the file ends up in one place and the file thinks it is ending up somewhere else.
in class ImageMacro.handleMacroCall: el.setAttribute( 'src', attachment.get_fileupload_url() ) That looks perfect to me - so I started looking at get_fileupload_url() and I do not see any special magic anywhere in WikiAttachment so I guess it's the django default action I get :( Any help is welcome, Per |
|
Posted by Herbert Poul |
|
most fileupload magic is done by django .. i'm just using the 'FileField' :)
http://www.djangoproject.com/documentation/model-api/#filefield but.. as you can see in the above link .. all upload should be in MEDIA_ROOT
so the files should be under <MEDIA_ROOT>/var/sphene/sphwiki/attachments/2008/05/22/ if you don't like the above after MEDIA_ROOT you can change it using the SPH_SETTING wiki_attachments_upload_to the default value is: 'wiki_attachments_upload_to': 'var/sphene/sphwiki/attachment/%Y/%m/%d', as for your first problem regarding the underscores (*_.*) .. unfortunately this is always added by django if it detects a file in the filesystem with the same name.. hmm.. i just tried it myself ... and i saw that if i upload a file once .. it will be stored twice.. this is weird .. i see if i can debug it .. at least i can reproduce the problem :| Hey, we have Signatures !!! Great, isn't it ? ;) |
|
Posted by Herbert Poul |
|
ok .. i found the problem..
the attachment got saved twice into the model's FileField ... once by the Form itself and a second time by myself in the view.. (don't ask me why i saved it a second time.. :( ) http://yourhell.com/wsvn/root/django/communitytools/trunk/sphenecoll/sphene/sphwiki/views.py?op=diff&rev=616&sc=1 anyway .. update from SCT trunk .. and it should work thanks for the bug report :) herbert Hey, we have Signatures !!! Great, isn't it ? ;) |
|
Posted by Per Strandberg |
|
No, I am happy with wherever they end up - that is related to my problem but not exactly my problem.
When I make an attachment I have difficulties linking to it from a wiki page. When I create a link (from within a wiki page) then...
So all links to attachments in the wiki snippets are wrong. Any ideas? Thanks, Per |
|
Posted by Herbert Poul |
|
are you sure you have defined MEDIA_URL in settings.py ?
the get_fileupload_url() should use settings.MEDIA_URL + filepath Hey, we have Signatures !!! Great, isn't it ? ;) |
|
Posted by Per Strandberg |
|
Ok, then I can be sure the problem is in my system any way.
Thanks, Per |
|
Posted by Herbert Poul |
|
FYI - MEDIA_ROOT is the path on the local filesystem to the media directory and MEDIA_URL is for the public URLs .. so maybe these two aren't set correctly for you ..
and check the django code django/db/models/base.py line 439 (method _get_FIELD_url): def _get_FIELD_url(self, field): if getattr(self, field.attname): # value is not blank import urlparse return urlparse.urljoin(settings.MEDIA_URL, getattr(self, field.attname)).replace('\\', '/') return '' this is where MEDIA_URL is prepanded to the file path .. so maybe you could start debugging there if you are still experiencing problems Hey, we have Signatures !!! Great, isn't it ? ;) |
|
Posted by Per Strandberg |
|
Of course!
My MEDIA_URL was just blank - for some reason we had missed it... Thanks :) :) :) /Per |
Please login to post a reply.