Hi,
I ran into two problems.
First: How to save Files in a custom directory based on the
filecontent?
Second: How to let the Database ensure that all Filenames are unique?

I've solved the first one by overriding the '_save_FIELD_file' -
Method of my Model, which is not nice since I do some djang-code
copying, but works.
I've also added a UNIQUE-Index to my 'file'-column.

What happens if the DB recognized that a filename already exists?
Django first creates a db entry with a blank value for 'file' and than
trys to fill it with the filename. The last action fails and so I've
got a new DB-Entry with no content.
This wouldn't even be too bad if I could still add more files. This is
not possible because django trys to create another entry with that
blank field and that fails because of  the UNIQUE-Index.

It seems to me that the problem is that filecreation and
filenameupdate is not atomar, not in one transaction.
Is that a Bug or a somewhat speed realated 'feature'?
Do you have a Hint for me how I could solve my problems more niftily?

mfg
- stanz

initially:
id | file
-----------------
00| 'myfilename'

insert same file:
00|'myfilename'
01|'' #Blank entry remains and no more files can be added


--~--~---------~--~----~------------~-------~--~----~
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