Author: jezdez
Date: 2010-12-01 19:03:00 -0600 (Wed, 01 Dec 2010)
New Revision: 14774

Modified:
   django/branches/releases/1.2.X/django/forms/fields.py
Log:
[1.2.X] Fixed #8217 -- Correctly sort files in FilePathFields on older Python 
versions. Thanks, bernd and davidb.

Backport from trunk (r14772).

Modified: django/branches/releases/1.2.X/django/forms/fields.py
===================================================================
--- django/branches/releases/1.2.X/django/forms/fields.py       2010-12-02 
01:02:11 UTC (rev 14773)
+++ django/branches/releases/1.2.X/django/forms/fields.py       2010-12-02 
01:03:00 UTC (rev 14774)
@@ -832,14 +832,14 @@
             self.match_re = re.compile(self.match)
 
         if recursive:
-            for root, dirs, files in os.walk(self.path):
+            for root, dirs, files in sorted(os.walk(self.path)):
                 for f in files:
                     if self.match is None or self.match_re.search(f):
                         f = os.path.join(root, f)
                         self.choices.append((f, f.replace(path, "", 1)))
         else:
             try:
-                for f in os.listdir(self.path):
+                for f in sorted(os.listdir(self.path)):
                     full_file = os.path.join(self.path, f)
                     if os.path.isfile(full_file) and (self.match is None or 
self.match_re.search(f)):
                         self.choices.append((full_file, f))

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to