diff options
| author | Gary Wilson Jr <gary.wilson@gmail.com> | 2008-08-10 21:10:47 +0000 |
|---|---|---|
| committer | Gary Wilson Jr <gary.wilson@gmail.com> | 2008-08-10 21:10:47 +0000 |
| commit | ef48a3e69c02438db32f20531f5c679e8315d528 (patch) | |
| tree | a60f57ad406aaa674ee8c742947872d2efc12cf4 /django/db/models | |
| parent | 94e8f4fb358fe39a67456f23f92eacd6f83e302d (diff) | |
Fixed #7830 -- Removed all of the remaining, deprecated, non-oldforms features:
* Support for representing files as strings was removed. Use `django.core.files.base.ContentFile` instead.
* Support for representing uploaded files as dictionaries was removed. Use `django.core.files.uploadedfile.SimpleUploadedFile` instead.
* The `filename`, `file_name`, `file_size`, and `chuck` properties of `UploadedFile` were removed. Use the `name`, `name`, `size`, and `chunks` properties instead, respectively.
* The `get_FIELD_filename`, `get_FIELD_url`, `get_FIELD_size`, and `save_FIELD_file` methods for Models with `FileField` fields were removed. Instead, use the `path`, `url`, and `size` attributes and `save` method on the field itself, respectively.
* The `get_FIELD_width` and `get_FIELD_height` methods for Models with `ImageField` fields were removed. Use the `width` and `height` attributes on the field itself instead.
* The dispatcher `connect`, `disconnect`, `send`, and `sendExact` functions were removed. Use the signal object's own `connect`, `disconnect`, `send`, and `send` methods instead, respectively.
* The `form_for_model` and `form_for_instance` functions were removed. Use a `ModelForm` subclass instead.
* Support for importing `django.newforms` was removed. Use `django.forms` instead.
* Support for importing `django.utils.images` was removed. Use `django.core.files.images` instead.
* Support for the `follow` argument in the `create_object` and `update_object` generic views was removed. Use the `django.forms` package and the new `form_class` argument instead.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8291 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/models')
| -rw-r--r-- | django/db/models/base.py | 38 | ||||
| -rw-r--r-- | django/db/models/fields/files.py | 28 |
2 files changed, 2 insertions, 64 deletions
diff --git a/django/db/models/base.py b/django/db/models/base.py index ed061e6634..f05699434c 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -3,7 +3,6 @@ import types import sys import os from itertools import izip -from warnings import warn try: set except NameError: @@ -477,43 +476,6 @@ class Model(object): setattr(self, cachename, obj) return getattr(self, cachename) - def _get_FIELD_filename(self, field): - warn("instance.get_%s_filename() is deprecated. Use instance.%s.path instead." % \ - (field.attname, field.attname), DeprecationWarning, stacklevel=3) - try: - return getattr(self, field.attname).path - except ValueError: - return '' - - def _get_FIELD_url(self, field): - warn("instance.get_%s_url() is deprecated. Use instance.%s.url instead." % \ - (field.attname, field.attname), DeprecationWarning, stacklevel=3) - try: - return getattr(self, field.attname).url - except ValueError: - return '' - - def _get_FIELD_size(self, field): - warn("instance.get_%s_size() is deprecated. Use instance.%s.size instead." % \ - (field.attname, field.attname), DeprecationWarning, stacklevel=3) - return getattr(self, field.attname).size - - def _save_FIELD_file(self, field, filename, content, save=True): - warn("instance.save_%s_file() is deprecated. Use instance.%s.save() instead." % \ - (field.attname, field.attname), DeprecationWarning, stacklevel=3) - return getattr(self, field.attname).save(filename, content, save) - - _save_FIELD_file.alters_data = True - - def _get_FIELD_width(self, field): - warn("instance.get_%s_width() is deprecated. Use instance.%s.width instead." % \ - (field.attname, field.attname), DeprecationWarning, stacklevel=3) - return getattr(self, field.attname).width() - - def _get_FIELD_height(self, field): - warn("instance.get_%s_height() is deprecated. Use instance.%s.height instead." % \ - (field.attname, field.attname), DeprecationWarning, stacklevel=3) - return getattr(self, field.attname).height() ############################################ diff --git a/django/db/models/fields/files.py b/django/db/models/fields/files.py index 76639596b5..935dee6162 100644 --- a/django/db/models/fields/files.py +++ b/django/db/models/fields/files.py @@ -192,10 +192,6 @@ class FileField(Field): def contribute_to_class(self, cls, name): super(FileField, self).contribute_to_class(cls, name) setattr(cls, self.name, FileDescriptor(self)) - setattr(cls, 'get_%s_filename' % self.name, curry(cls._get_FIELD_filename, field=self)) - setattr(cls, 'get_%s_url' % self.name, curry(cls._get_FIELD_url, field=self)) - setattr(cls, 'get_%s_size' % self.name, curry(cls._get_FIELD_size, field=self)) - setattr(cls, 'save_%s_file' % self.name, lambda instance, name, content, save=True: instance._save_FIELD_file(self, name, content, save)) signals.post_delete.connect(self.delete_file, sender=cls) def delete_file(self, instance, sender, **kwargs): @@ -262,26 +258,15 @@ class FileField(Field): class ImageFieldFile(ImageFile, FieldFile): def save(self, name, content, save=True): - - if not hasattr(content, 'read'): - import warnings - warnings.warn( - message = "Representing files as strings is deprecated." \ - "Use django.core.files.base.ContentFile instead.", - category = DeprecationWarning, - stacklevel = 2 - ) - content = ContentFile(content) - # Repopulate the image dimension cache. self._dimensions_cache = get_image_dimensions(content) - + # Update width/height fields, if needed if self.field.width_field: setattr(self.instance, self.field.width_field, self.width) if self.field.height_field: setattr(self.instance, self.field.height_field, self.height) - + super(ImageFieldFile, self).save(name, content, save) def delete(self, save=True): @@ -300,15 +285,6 @@ class ImageField(FileField): def get_manipulator_field_objs(self): return [oldforms.ImageUploadField, oldforms.HiddenField] - def contribute_to_class(self, cls, name): - super(ImageField, self).contribute_to_class(cls, name) - # Add get_BLAH_width and get_BLAH_height methods, but only if the - # image field doesn't have width and height cache fields. - if not self.width_field: - setattr(cls, 'get_%s_width' % self.name, curry(cls._get_FIELD_width, field=self)) - if not self.height_field: - setattr(cls, 'get_%s_height' % self.name, curry(cls._get_FIELD_height, field=self)) - def formfield(self, **kwargs): defaults = {'form_class': forms.ImageField} defaults.update(kwargs) |
