Sphene Community Tools

Community

Copyright © 2007-2018 by Herbert Poul

You are not logged in.
Login
Register

Change Language:



AddThis Social Bookmark Button

A Django site.

Powered by Sphene Community Tools
Board » General » How do you configure the upload path?

Uploads are not working on my site. When I try and upload something I get a really odd totally empty page (after a good 30 seconds of waiting).

I still do not have logging working correctly so I cannot tell if something is blowing up with a stack trace.

In poking around I think that the files are supposed to be saved by a call to

attachment.save_fileupload_file( reqdata['fileupload']['filename'], reqdata['fileupload']['content'] )


Which is a method I cannot find the definition for by grepping the name in the SCT tools source or the Django source. Which is very weird. Where does this function live?

There are also a series of settings based on *upload_to paths which all seem to be relative URLs. The defaults are to various var directories:

var/sphene/sphwiki/attachment

Which I think get added to the static directory. Which means that the static directory needs to be writable by the http process.

After trying all of the above (and a few more items) I still can't get any upload (avatar, post attachment, etc.) to succeed.

What is the missing link here?

Thanks!

--- Last Edited by Leeland at 2008-06-10 19:39:12 ---
the methods are dynamically added by django .. every file field in a model gets a few "magic" functions

the whole upload thing is handled by django .. i am simply defining a FileField in the models ..
see: http://www.djangoproject.com/documentation/model-api/#filefield

the upload_to is always below MEDIA_ROOT .. and i've made it configurable in SCT by setting SPH_SETTINGS['wiki_attachments_upload_to'] or anything else.. which by default always is something like 'var/sphene/...' .. so make sure your 'var' directory in MEDIA_ROOT is writable..

this should do the trick..
Hey, we have Signatures !!! Great, isn't it ? ;)
So you have 2 directories static and media. In the URLs for this place the avatars are in static. But you are saying they are uploaded to media. So are you mixing the two places?
Well that was odd. I have a media directory and a static directory. They are separate. I tried setting both of them to writable by the user which is running the web service. But, I still couldn't upload my avatar, forum attachments or wiki attachments. So I created the directories var/sphene/ in both media and static again making them owned by the web services user. Still didn't work. Then I restarted the web service. Now they work just fine and they created the extra directories as needed (e.g. sphwiki/attachment/2008/06/10/).

Seems that these directories are checked only on start up and not after.

Oh and when I upload the files are created in the static directory not the media directory (which matches up with what happens here too).
i think i'm a bit confused.. there is a difference between static and media directories ? i thought they are both the same ? there is only a MEDIA_ROOT AND MEDIA_URL setting afaik

and well .. creating directories, uploading & co is all in django's code.. i haven't looked at it if it's checking it on every request or just when launching ..
Hey, we have Signatures !!! Great, isn't it ? ;)
OK I went and looked at the actual files. Yes there is a difference. Here is the settings from the communitydraft/community/settings.py

# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = os.path.join(ROOT_PATH,'..','static')

# URL that handles the media served from MEDIA_ROOT.
# Example: "http://media.lawrence.com"
MEDIA_URL = '/static/'

# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = '/media/'


So this is where my confusion was coming in. There is the ADMIN_MEDIA_PREFIX which is really only for the media files associated with the Django built in specialized interfaces. Then there is the MEDIA_ROOT which could be better named to SITE_MANAGED_FILES_ROOT.

So MEDIA_ROOT and MEDIA_URL point to 'static' while ADMIN_MEDIA_PREFIX points to a separate space. Both MEDIA_URL and ADMIN_MEDIA_PREFIX are served by my lighttpd service and not Django (why waste python cycles for static content)?

I got it figured out now.

Please login to post a reply.



Powered by Sphene Community Tools