As Malcolm mentioned, I put a lot of time into a patch to solve a
great many problems with FileField, even more than the ones you
mentioned. It's not in trunk yet, and I don't know when it will be,
but I'll answer your questions to give you an overview of how things
will likely work. Keep in mind that it does more than this, but since
these are your concerns, I'll address just those.

> * I don't want to store the files in MEDIA_ROOT, since
>    the access needs to go through django for authentication.

The new patch allows you to specify any root location you like,
independent of MEDIA_ROOT. You can even specify a root for any or all
of the FileFields in your project.

> * The containing directory should be given by the model of the FileField.
>   Example:
>
> class MyFriend(models.Model):
>     picture=models.NewFileField(...)
>
>    if myfriend has id=1234 the file should be in .../myfriends/1234/

Given that you would be able to specify a different root directory for
each FileField, the model name would be easy to include, it just
wouldn't be automatic. As for including the ID as part of the path,
that's something a few other people have requested, and I'm still
trying to work out if there's a decent way to go about that. As it
stands, the patch doesn't support it.

> * Unicode filenames should be encoded in pure ascii in the filesystem.
>    The encoding should be reversable, so that you can get the unicode
>    string back. This could be done with utils.http.urlquote().
>
> * The database should contain the unicode filename.

I'm not a unicode expert, so I won't pretend to know about the
"should" aspect of this, I'll defer to Malcolm on that. The patch
would, as Malcolm mentioned, provide a way for you to override how the
FileField generates the filename for use on the filesystem, as well as
what's stored in the database. So it would be fairly simple to include
this functionality on your own, even if it's not part of the standard
mechanism.

> Has someone the same problems?

Yes, and more. :)

> Has someone solved/coded this?

Mostly.

> This patch only uses a better filename normalization:
> http://code.djangoproject.com/ticket/3119
> The unicode name get's lost.

The new FileField patch provides a different (better, in my opinion)
approach to this, so I expect that ticket would end up getting closed
with a note on how to use the new system to do the same thing. We'll
see.

-Gul

--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to