I'm working on a little app to manage a podcast RSS feed (believe it
or not, someboody actually edits it by hand now). So my first thought
was to use the FileField for uploading the enclosure. This worked fine
except for one issue: The podcast in question is for video, and the
files are typically 200 MB. I watched top while uploading one of these
and the mini-dev server went up to 1.5 GB resident (good thing I had 2
GB of RAM), but obviously this presents a problem. I don't know if
apache/mod_python would work any better or not. I'm guessing the
django server simply reads the entire request into memory and then
parses, while apache may start writing to a temp file somewhere.

Anyway. To work around this particular problem I changed it to a
FilePathField and stipulated that the files (which were already on the
server) would be uploaded by some other means. There are a couple
problems with this:

1) You lose all the nice get_*_url(), get_*_size() and friends that
FileField gives you.

2) To use an existing directory structure, I had to use the recursive
option, but it seems that the value that is stored loses any
subdirectory name between the path and the actual file. I filed a bug
with a patch for this (magic-removal):

http://code.djangoproject.com/ticket/1536

3) It stores the complete path in the database, and there's no obvious
way to trim the path down so you can paste the subdirectory/filename
onto the end of a URL short of repeating yourself and manually
clipping off the initial path, and there's no way I can see to get
that value out of the model. i.e. If I am using:

    enclosure = models.FilePathField(path="/var/media/podcasts",
recursive=True, match="\.mp4$")

and I select the file /var/media/podcasts/banking/commercial.mp4,
there's not a way I can get it to just chop off the original path. I
suppose I could do this:

PODCAST_PATH = '/var/media/podcasts'

...

    enclosure = models.FilePathField(path=PODCAST_PATH,
recursive=True, match="\.mp4$")

    def get_enclosure_uri(self):
        return enclosure[len(PODCAST_PATH):]

and then use {{ MEDIA_URL }}/{{ object.get_enclosure_uri }} in the
template. (or something like that)

Any other suggestions? Maybe a variant of FileField or an additional
option that disables upload in the admin interface but let's you pick
matching files out of MEDIA_ROOT?
--
The Pythonic Principle: Python works the way it does
because if it didn't, it wouldn't be Python.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to