comparison gpp/downloads/models.py @ 210:77b606e0ad5f

Fix #78: improve the download upload_to path.
author Brian Neal <bgneal@gmail.com>
date Fri, 07 May 2010 02:56:49 +0000
parents 272d3a8c98e8
children 8d13baeaa5c1
comparison
equal deleted inserted replaced
209:0e7c7231dea9 210:77b606e0ad5f
31 clashes. Uses the current microsecond also to make the directory name 31 clashes. Uses the current microsecond also to make the directory name
32 harder to guess. 32 harder to guess.
33 """ 33 """
34 now = datetime.datetime.now() 34 now = datetime.datetime.now()
35 parts = ['downloads'] 35 parts = ['downloads']
36 parts.extend([str(p) for p in (now.year, now.month, now.day, now.microsecond)]) 36 parts.extend([str(p) for p in (now.year, now.month, now.day)])
37 parts.append(hex((now.hour * 3600 + now.minute * 60 + now.second) * 1000 + (
38 now.microsecond / 1000))[2:])
37 parts.append(filename) 39 parts.append(filename)
38 return os.path.join(*parts) 40 return os.path.join(*parts)
39 41
40 42
41 class PublicDownloadManager(models.Manager): 43 class PublicDownloadManager(models.Manager):