summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Bauer <gb@hugo.westfalen.de>2005-10-13 16:21:40 +0000
committerGeorg Bauer <gb@hugo.westfalen.de>2005-10-13 16:21:40 +0000
commit2ffca1711ddd58ce0457bbf972a25402b746b73b (patch)
tree628b5102561bb01f722c6e8730397f8d9b9ae28b
parentb61aee47fc632730ac4cbfccdc6961e743be5dc1 (diff)
parent84a30e709677deea2f4b2ce6661329d76b73e9b0 (diff)
i18n: merged to r852
git-svn-id: http://code.djangoproject.com/svn/django/branches/i18n@853 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/core/db/backends/mysql.py1
-rw-r--r--django/core/db/backends/postgresql.py1
-rw-r--r--django/core/db/backends/sqlite3.py1
-rw-r--r--django/core/formfields.py23
-rw-r--r--django/core/meta/fields.py8
-rw-r--r--docs/install.txt12
-rw-r--r--docs/model-api.txt35
-rw-r--r--docs/modpython.txt3
8 files changed, 76 insertions, 8 deletions
diff --git a/django/core/db/backends/mysql.py b/django/core/db/backends/mysql.py
index 2e77adbc43..af0dbca6c0 100644
--- a/django/core/db/backends/mysql.py
+++ b/django/core/db/backends/mysql.py
@@ -143,6 +143,7 @@ DATA_TYPES = {
'DateTimeField': 'datetime',
'EmailField': 'varchar(75)',
'FileField': 'varchar(100)',
+ 'FilePathField': 'varchar(100)',
'FloatField': 'numeric(%(max_digits)s, %(decimal_places)s)',
'ImageField': 'varchar(100)',
'IntegerField': 'integer',
diff --git a/django/core/db/backends/postgresql.py b/django/core/db/backends/postgresql.py
index 683ae3c9ee..6ec7bfbfcb 100644
--- a/django/core/db/backends/postgresql.py
+++ b/django/core/db/backends/postgresql.py
@@ -154,6 +154,7 @@ DATA_TYPES = {
'DateTimeField': 'timestamp with time zone',
'EmailField': 'varchar(75)',
'FileField': 'varchar(100)',
+ 'FilePathField': 'varchar(100)',
'FloatField': 'numeric(%(max_digits)s, %(decimal_places)s)',
'ImageField': 'varchar(100)',
'IntegerField': 'integer',
diff --git a/django/core/db/backends/sqlite3.py b/django/core/db/backends/sqlite3.py
index d4b936f82e..ea05302a61 100644
--- a/django/core/db/backends/sqlite3.py
+++ b/django/core/db/backends/sqlite3.py
@@ -154,6 +154,7 @@ DATA_TYPES = {
'DateTimeField': 'datetime',
'EmailField': 'varchar(75)',
'FileField': 'varchar(100)',
+ 'FilePathField': 'varchar(100)',
'FloatField': 'numeric(%(max_digits)s, %(decimal_places)s)',
'ImageField': 'varchar(100)',
'IntegerField': 'integer',
diff --git a/django/core/formfields.py b/django/core/formfields.py
index 76721ba5c6..9b9f0af1d1 100644
--- a/django/core/formfields.py
+++ b/django/core/formfields.py
@@ -707,6 +707,29 @@ class IPAddressField(TextField):
# MISCELLANEOUS #
####################
+class FilePathField(SelectField):
+ "A SelectField whose choices are the files in a given directory."
+ def __init__(self, field_name, path, match=None, recursive=False, is_required=False, validator_list=[]):
+ import os
+ if match is not None:
+ import re
+ match_re = re.compile(match)
+ choices = []
+ if recursive:
+ for root, dirs, files in os.walk(path):
+ for f in files:
+ if match is None or match_re.search(f):
+ choices.append((os.path.join(path, f), f))
+ else:
+ try:
+ for f in os.listdir(path):
+ full_file = os.path.join(path, f)
+ if os.path.isfile(full_file) and (match is None or match_re.search(f)):
+ choices.append((full_file, f))
+ except OSError:
+ pass
+ SelectField.__init__(self, field_name, choices, 1, is_required, validator_list)
+
class PhoneNumberField(TextField):
"A convenience FormField for validating phone numbers (e.g. '630-555-1234')"
def __init__(self, field_name, is_required=False, validator_list=[]):
diff --git a/django/core/meta/fields.py b/django/core/meta/fields.py
index 376595230c..0740010579 100644
--- a/django/core/meta/fields.py
+++ b/django/core/meta/fields.py
@@ -427,6 +427,14 @@ class FileField(Field):
f = os.path.join(self.get_directory_name(), get_valid_filename(os.path.basename(filename)))
return os.path.normpath(f)
+class FilePathField(Field):
+ def __init__(self, verbose_name=None, name=None, path='', match=None, recursive=False, **kwargs):
+ self.path, self.match, self.recursive = path, match, recursive
+ Field.__init__(self, verbose_name, name, **kwargs)
+
+ def get_manipulator_field_objs(self):
+ return [curry(formfields.FilePathField, path=self.path, match=self.match, recursive=self.recursive)]
+
class FloatField(Field):
empty_strings_allowed = False
def __init__(self, verbose_name=None, name=None, max_digits=None, decimal_places=None, **kwargs):
diff --git a/docs/install.txt b/docs/install.txt
index b347006cbb..b18d26d5c8 100644
--- a/docs/install.txt
+++ b/docs/install.txt
@@ -21,14 +21,15 @@ See `How to use Django with mod_python`_ for information on how to configure
mod_python once you have it installed.
If you can't use mod_python for some reason, fear not: Django follows the WSGI_
-spec, which allows it to run on a variety of server platforms. As people
-experiment with different server platforms, we'll update this document to
-give specific installation instructions for each platform.
+spec, which allows it to run on a variety of server platforms. See the
+`server-arrangements wiki page`_ for specific installation instructions for
+each platform.
.. _Apache: http://httpd.apache.org/
.. _mod_python: http://www.modpython.org/
.. _WSGI: http://www.python.org/peps/pep-0333.html
.. _How to use Django with mod_python: http://www.djangoproject.com/documentation/modpython/
+.. _server-arrangements wiki page: http://code.djangoproject.com/wiki/ServerArrangements
Get your database running
=========================
@@ -37,11 +38,6 @@ If you plan to use Django's database API functionality, you'll need to
make sure a database server is running. Django works with PostgreSQL_
(recommended), MySQL_ and SQLite_.
-Note that support for MySQL and SQLite is a recent development, and Django
-hasn't been comprehensively tested in those environments. If you find any bugs
-in Django's MySQL or SQLite bindings, please file them in
-`Django's ticket system`_ so we can fix them immediately.
-
Additionally, you'll need to make sure your Python database bindings are
installed.
diff --git a/docs/model-api.txt b/docs/model-api.txt
index 2ad2b3594d..140518e80e 100644
--- a/docs/model-api.txt
+++ b/docs/model-api.txt
@@ -272,6 +272,41 @@ Here are all available field types:
.. _`strftime formatting`: http://docs.python.org/lib/module-time.html#l2h-1941
+``FilePathField``
+ A field whose choices are limited to the filenames in a certain directory
+ on the filesystem. Has three special arguments, of which the first is
+ required:
+
+ ====================== ===================================================
+ Argument Description
+ ====================== ===================================================
+ ``path`` Required. The absolute filesystem path to a
+ directory from which this ``FilePathField`` should
+ get its choices. Example: ``"/home/images"``.
+
+ ``match`` Optional. A regular expression, as a string, that
+ ``FilePathField`` will use to filter filenames.
+ Note that the regex will be applied to the
+ base filename, not the full path. Example:
+ ``"foo.*\.txt^"``, which will match a file called
+ ``foo23.txt`` but not ``bar.txt`` or ``foo23.gif``.
+
+ ``recursive`` Optional. Either ``True`` or ``False``. Default is
+ ``False``. Specifies whether all subdirectories of
+ ``path`` should be included.
+ ====================== ===================================================
+
+ Of course, these arguments can be used together.
+
+ The one potential gotcha is that ``match`` applies to the base filename,
+ not the full path. So, this example::
+
+ FilePathField(path="/home/images", match="foo.*", recursive=True)
+
+ ...will match ``/home/images/foo.gif`` but not ``/home/images/foo/bar.gif``
+ because the ``match`` applies to the base filename (``foo.gif`` and
+ ``bar.gif``).
+
``FloatField``
A floating-point number. Has two **required** arguments:
diff --git a/docs/modpython.txt b/docs/modpython.txt
index acac50a6d5..d24ea29018 100644
--- a/docs/modpython.txt
+++ b/docs/modpython.txt
@@ -143,6 +143,9 @@ particular part of the site::
Just change ``Location`` to the root URL of your media files.
+Note that the Django development server automagically serves admin media files,
+but this is not the case when you use any other server arrangement.
+
.. _lighttpd: http://www.lighttpd.net/
.. _TUX: http://en.wikipedia.org/wiki/TUX_web_server
.. _Apache: http://httpd.apache.org/