Changeset 853
- Timestamp:
- 10/13/05 11:21:40 (3 years ago)
- Files:
-
- django/branches/i18n/django/core/db/backends/mysql.py (modified) (1 diff)
- django/branches/i18n/django/core/db/backends/postgresql.py (modified) (1 diff)
- django/branches/i18n/django/core/db/backends/sqlite3.py (modified) (1 diff)
- django/branches/i18n/django/core/formfields.py (modified) (1 diff)
- django/branches/i18n/django/core/meta/fields.py (modified) (1 diff)
- django/branches/i18n/docs/install.txt (modified) (3 diffs)
- django/branches/i18n/docs/model-api.txt (modified) (1 diff)
- django/branches/i18n/docs/modpython.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/i18n/django/core/db/backends/mysql.py
r815 r853 144 144 'EmailField': 'varchar(75)', 145 145 'FileField': 'varchar(100)', 146 'FilePathField': 'varchar(100)', 146 147 'FloatField': 'numeric(%(max_digits)s, %(decimal_places)s)', 147 148 'ImageField': 'varchar(100)', django/branches/i18n/django/core/db/backends/postgresql.py
r713 r853 155 155 'EmailField': 'varchar(75)', 156 156 'FileField': 'varchar(100)', 157 'FilePathField': 'varchar(100)', 157 158 'FloatField': 'numeric(%(max_digits)s, %(decimal_places)s)', 158 159 'ImageField': 'varchar(100)', django/branches/i18n/django/core/db/backends/sqlite3.py
r713 r853 155 155 'EmailField': 'varchar(75)', 156 156 'FileField': 'varchar(100)', 157 'FilePathField': 'varchar(100)', 157 158 'FloatField': 'numeric(%(max_digits)s, %(decimal_places)s)', 158 159 'ImageField': 'varchar(100)', django/branches/i18n/django/core/formfields.py
r787 r853 708 708 #################### 709 709 710 class FilePathField(SelectField): 711 "A SelectField whose choices are the files in a given directory." 712 def __init__(self, field_name, path, match=None, recursive=False, is_required=False, validator_list=[]): 713 import os 714 if match is not None: 715 import re 716 match_re = re.compile(match) 717 choices = [] 718 if recursive: 719 for root, dirs, files in os.walk(path): 720 for f in files: 721 if match is None or match_re.search(f): 722 choices.append((os.path.join(path, f), f)) 723 else: 724 try: 725 for f in os.listdir(path): 726 full_file = os.path.join(path, f) 727 if os.path.isfile(full_file) and (match is None or match_re.search(f)): 728 choices.append((full_file, f)) 729 except OSError: 730 pass 731 SelectField.__init__(self, field_name, choices, 1, is_required, validator_list) 732 710 733 class PhoneNumberField(TextField): 711 734 "A convenience FormField for validating phone numbers (e.g. '630-555-1234')" django/branches/i18n/django/core/meta/fields.py
r815 r853 428 428 return os.path.normpath(f) 429 429 430 class FilePathField(Field): 431 def __init__(self, verbose_name=None, name=None, path='', match=None, recursive=False, **kwargs): 432 self.path, self.match, self.recursive = path, match, recursive 433 Field.__init__(self, verbose_name, name, **kwargs) 434 435 def get_manipulator_field_objs(self): 436 return [curry(formfields.FilePathField, path=self.path, match=self.match, recursive=self.recursive)] 437 430 438 class FloatField(Field): 431 439 empty_strings_allowed = False django/branches/i18n/docs/install.txt
r484 r853 22 22 23 23 If you can't use mod_python for some reason, fear not: Django follows the WSGI_ 24 spec, which allows it to run on a variety of server platforms. As people25 experiment with different server platforms, we'll update this document to 26 give specific installation instructions foreach platform.24 spec, which allows it to run on a variety of server platforms. See the 25 `server-arrangements wiki page`_ for specific installation instructions for 26 each platform. 27 27 28 28 .. _Apache: http://httpd.apache.org/ … … 30 30 .. _WSGI: http://www.python.org/peps/pep-0333.html 31 31 .. _How to use Django with mod_python: http://www.djangoproject.com/documentation/modpython/ 32 .. _server-arrangements wiki page: http://code.djangoproject.com/wiki/ServerArrangements 32 33 33 34 Get your database running … … 37 38 make sure a database server is running. Django works with PostgreSQL_ 38 39 (recommended), MySQL_ and SQLite_. 39 40 Note that support for MySQL and SQLite is a recent development, and Django41 hasn't been comprehensively tested in those environments. If you find any bugs42 in Django's MySQL or SQLite bindings, please file them in43 `Django's ticket system`_ so we can fix them immediately.44 40 45 41 Additionally, you'll need to make sure your Python database bindings are django/branches/i18n/docs/model-api.txt
r844 r853 272 272 273 273 .. _`strftime formatting`: http://docs.python.org/lib/module-time.html#l2h-1941 274 275 ``FilePathField`` 276 A field whose choices are limited to the filenames in a certain directory 277 on the filesystem. Has three special arguments, of which the first is 278 required: 279 280 ====================== =================================================== 281 Argument Description 282 ====================== =================================================== 283 ``path`` Required. The absolute filesystem path to a 284 directory from which this ``FilePathField`` should 285 get its choices. Example: ``"/home/images"``. 286 287 ``match`` Optional. A regular expression, as a string, that 288 ``FilePathField`` will use to filter filenames. 289 Note that the regex will be applied to the 290 base filename, not the full path. Example: 291 ``"foo.*\.txt^"``, which will match a file called 292 ``foo23.txt`` but not ``bar.txt`` or ``foo23.gif``. 293 294 ``recursive`` Optional. Either ``True`` or ``False``. Default is 295 ``False``. Specifies whether all subdirectories of 296 ``path`` should be included. 297 ====================== =================================================== 298 299 Of course, these arguments can be used together. 300 301 The one potential gotcha is that ``match`` applies to the base filename, 302 not the full path. So, this example:: 303 304 FilePathField(path="/home/images", match="foo.*", recursive=True) 305 306 ...will match ``/home/images/foo.gif`` but not ``/home/images/foo/bar.gif`` 307 because the ``match`` applies to the base filename (``foo.gif`` and 308 ``bar.gif``). 274 309 275 310 ``FloatField`` django/branches/i18n/docs/modpython.txt
r775 r853 144 144 Just change ``Location`` to the root URL of your media files. 145 145 146 Note that the Django development server automagically serves admin media files, 147 but this is not the case when you use any other server arrangement. 148 146 149 .. _lighttpd: http://www.lighttpd.net/ 147 150 .. _TUX: http://en.wikipedia.org/wiki/TUX_web_server
