Django

Code

Changeset 853

Show
Ignore:
Timestamp:
10/13/05 11:21:40 (3 years ago)
Author:
hugo
Message:

i18n: merged to r852

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/i18n/django/core/db/backends/mysql.py

    r815 r853  
    144144    'EmailField':        'varchar(75)', 
    145145    'FileField':         'varchar(100)', 
     146    'FilePathField':     'varchar(100)', 
    146147    'FloatField':        'numeric(%(max_digits)s, %(decimal_places)s)', 
    147148    'ImageField':        'varchar(100)', 
  • django/branches/i18n/django/core/db/backends/postgresql.py

    r713 r853  
    155155    'EmailField':        'varchar(75)', 
    156156    'FileField':         'varchar(100)', 
     157    'FilePathField':     'varchar(100)', 
    157158    'FloatField':        'numeric(%(max_digits)s, %(decimal_places)s)', 
    158159    'ImageField':        'varchar(100)', 
  • django/branches/i18n/django/core/db/backends/sqlite3.py

    r713 r853  
    155155    'EmailField':                   'varchar(75)', 
    156156    'FileField':                    'varchar(100)', 
     157    'FilePathField':                'varchar(100)', 
    157158    'FloatField':                   'numeric(%(max_digits)s, %(decimal_places)s)', 
    158159    'ImageField':                   'varchar(100)', 
  • django/branches/i18n/django/core/formfields.py

    r787 r853  
    708708#################### 
    709709 
     710class 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 
    710733class PhoneNumberField(TextField): 
    711734    "A convenience FormField for validating phone numbers (e.g. '630-555-1234')" 
  • django/branches/i18n/django/core/meta/fields.py

    r815 r853  
    428428        return os.path.normpath(f) 
    429429 
     430class 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 
    430438class FloatField(Field): 
    431439    empty_strings_allowed = False 
  • django/branches/i18n/docs/install.txt

    r484 r853  
    2222 
    2323If 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 peopl
    25 experiment with different server platforms, we'll update this document to 
    26 give specific installation instructions for each platform. 
     24spec, which allows it to run on a variety of server platforms. See th
     25`server-arrangements wiki page`_ for specific installation instructions for 
     26each platform. 
    2727 
    2828.. _Apache: http://httpd.apache.org/ 
     
    3030.. _WSGI: http://www.python.org/peps/pep-0333.html 
    3131.. _How to use Django with mod_python: http://www.djangoproject.com/documentation/modpython/ 
     32.. _server-arrangements wiki page: http://code.djangoproject.com/wiki/ServerArrangements 
    3233 
    3334Get your database running 
     
    3738make sure a database server is running. Django works with PostgreSQL_ 
    3839(recommended), MySQL_ and SQLite_. 
    39  
    40 Note that support for MySQL and SQLite is a recent development, and Django 
    41 hasn't been comprehensively tested in those environments. If you find any bugs 
    42 in Django's MySQL or SQLite bindings, please file them in 
    43 `Django's ticket system`_ so we can fix them immediately. 
    4440 
    4541Additionally, you'll need to make sure your Python database bindings are 
  • django/branches/i18n/docs/model-api.txt

    r844 r853  
    272272 
    273273    .. _`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``). 
    274309 
    275310``FloatField`` 
  • django/branches/i18n/docs/modpython.txt

    r775 r853  
    144144Just change ``Location`` to the root URL of your media files. 
    145145 
     146Note that the Django development server automagically serves admin media files, 
     147but this is not the case when you use any other server arrangement. 
     148 
    146149.. _lighttpd: http://www.lighttpd.net/ 
    147150.. _TUX: http://en.wikipedia.org/wiki/TUX_web_server