summaryrefslogtreecommitdiff
path: root/django/core
diff options
context:
space:
mode:
authorGary Wilson Jr <gary.wilson@gmail.com>2008-08-10 21:10:47 +0000
committerGary Wilson Jr <gary.wilson@gmail.com>2008-08-10 21:10:47 +0000
commitef48a3e69c02438db32f20531f5c679e8315d528 (patch)
treea60f57ad406aaa674ee8c742947872d2efc12cf4 /django/core
parent94e8f4fb358fe39a67456f23f92eacd6f83e302d (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/core')
-rw-r--r--django/core/files/storage.py13
-rw-r--r--django/core/files/uploadedfile.py71
2 files changed, 5 insertions, 79 deletions
diff --git a/django/core/files/storage.py b/django/core/files/storage.py
index a0732e9003..fcad86fda0 100644
--- a/django/core/files/storage.py
+++ b/django/core/files/storage.py
@@ -36,19 +36,6 @@ class Storage(object):
Saves new content to the file specified by name. The content should be a
proper File object, ready to be read from the beginning.
"""
- # Check for old-style usage. Warn here first since there are multiple
- # locations where we need to support both new and old usage.
- if isinstance(content, basestring):
- import warnings
- warnings.warn(
- message = "Representing files as strings is deprecated." \
- "Use django.core.files.base.ContentFile instead.",
- category = DeprecationWarning,
- stacklevel = 2
- )
- from django.core.files.base import ContentFile
- content = ContentFile(content)
-
# Get the proper name for the file, as it will actually be saved.
if name is None:
name = content.name
diff --git a/django/core/files/uploadedfile.py b/django/core/files/uploadedfile.py
index a5a12930e3..afbcdba0f0 100644
--- a/django/core/files/uploadedfile.py
+++ b/django/core/files/uploadedfile.py
@@ -3,7 +3,6 @@ Classes representing uploaded files.
"""
import os
-import warnings
try:
from cStringIO import StringIO
except ImportError:
@@ -11,34 +10,10 @@ except ImportError:
from django.conf import settings
from django.core.files.base import File
-
from django.core.files import temp as tempfile
-__all__ = ('UploadedFile', 'TemporaryUploadedFile', 'InMemoryUploadedFile', 'SimpleUploadedFile')
-
-# Because we fooled around with it a bunch, UploadedFile has a bunch
-# of deprecated properties. This little shortcut helps define 'em
-# without too much code duplication.
-def deprecated_property(old, new, readonly=False):
- def issue_warning():
- warnings.warn(
- message = "UploadedFile.%s is deprecated; use UploadedFile.%s instead." % (old, new),
- category = DeprecationWarning,
- stacklevel = 3
- )
-
- def getter(self):
- issue_warning()
- return getattr(self, new)
-
- def setter(self, value):
- issue_warning()
- setattr(self, new, value)
-
- if readonly:
- return property(getter)
- else:
- return property(getter, setter)
+__all__ = ('UploadedFile', 'TemporaryUploadedFile', 'InMemoryUploadedFile',
+ 'SimpleUploadedFile')
class UploadedFile(File):
"""
@@ -77,21 +52,6 @@ class UploadedFile(File):
name = property(_get_name, _set_name)
- # Deprecated properties
- filename = deprecated_property(old="filename", new="name")
- file_name = deprecated_property(old="file_name", new="name")
- file_size = deprecated_property(old="file_size", new="size")
- chunk = deprecated_property(old="chunk", new="chunks", readonly=True)
-
- def _get_data(self):
- warnings.warn(
- message = "UploadedFile.data is deprecated; use UploadedFile.read() instead.",
- category = DeprecationWarning,
- stacklevel = 2
- )
- return self.read()
- data = property(_get_data)
-
# Abstract methods; subclasses *must* define read() and probably should
# define open/close.
def read(self, num_bytes=None):
@@ -103,27 +63,6 @@ class UploadedFile(File):
def close(self):
pass
- # Backwards-compatible support for uploaded-files-as-dictionaries.
- def __getitem__(self, key):
- warnings.warn(
- message = "The dictionary access of uploaded file objects is deprecated. Use the new object interface instead.",
- category = DeprecationWarning,
- stacklevel = 2
- )
- backwards_translate = {
- 'filename': 'name',
- 'content-type': 'content_type',
- }
-
- if key == 'content':
- return self.read()
- elif key == 'filename':
- return self.name
- elif key == 'content-type':
- return self.content_type
- else:
- return getattr(self, key)
-
class TemporaryUploadedFile(UploadedFile):
"""
A file uploaded to a temporary location (i.e. stream-to-disk).
@@ -140,7 +79,7 @@ class TemporaryUploadedFile(UploadedFile):
Returns the full path of this file.
"""
return self._file.name
-
+
# Most methods on this object get proxied to NamedTemporaryFile.
# We can't directly subclass because NamedTemporaryFile is actually a
# factory function
@@ -159,9 +98,9 @@ class TemporaryUploadedFile(UploadedFile):
# Still sets self._file.close_called and calls self._file.file.close()
# before the exception
return
- else:
+ else:
raise e
-
+
class InMemoryUploadedFile(UploadedFile):
"""
A file uploaded into memory (i.e. stream-to-memory).