Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Removed several deprecated features for 1.0 (refs #7830):
 * "simple" cache backend
 * `ObjectPaginator`
 * `edit_inline_type` argument for `ForeignKey` fields
 * `QOperator`, `QNot`, `QAnd` and `QOr`
 * `maxlength` argument 


git-svn-id: http://code.djangoproject.com/svn/django/trunk@8191 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
gdub committed Aug 2, 2008
1 parent cbbd54d commit 351a3ca
Show file tree
Hide file tree
Showing 17 changed files with 10 additions and 464 deletions.
10 changes: 0 additions & 10 deletions django/core/cache/__init__.py
Expand Up @@ -30,22 +30,12 @@
'dummy': 'dummy',
}

DEPRECATED_BACKENDS = {
# deprecated backend --> replacement module
'simple': 'locmem',
}

def get_cache(backend_uri):
if backend_uri.find(':') == -1:
raise InvalidCacheBackendError, "Backend URI must start with scheme://"
scheme, rest = backend_uri.split(':', 1)
if not rest.startswith('//'):
raise InvalidCacheBackendError, "Backend URI must start with scheme://"
if scheme in DEPRECATED_BACKENDS:
import warnings
warnings.warn("'%s' backend is deprecated. Use '%s' instead." %
(scheme, DEPRECATED_BACKENDS[scheme]), DeprecationWarning)
scheme = DEPRECATED_BACKENDS[scheme]

host = rest[2:]
qpos = rest.find('?')
Expand Down
62 changes: 0 additions & 62 deletions django/core/paginator.py
Expand Up @@ -118,65 +118,3 @@ def end_index(self):
if self.number == self.paginator.num_pages:
return self.paginator.count
return self.number * self.paginator.per_page

class ObjectPaginator(Paginator):
"""
Legacy ObjectPaginator class, for backwards compatibility.
Note that each method on this class that takes page_number expects a
zero-based page number, whereas the new API (Paginator/Page) uses one-based
page numbers.
"""
def __init__(self, query_set, num_per_page, orphans=0):
Paginator.__init__(self, query_set, num_per_page, orphans)
import warnings
warnings.warn("The ObjectPaginator is deprecated. Use django.core.paginator.Paginator instead.", DeprecationWarning)

# Keep these attributes around for backwards compatibility.
self.query_set = query_set
self.num_per_page = num_per_page
self._hits = self._pages = None

def validate_page_number(self, page_number):
try:
page_number = int(page_number) + 1
except ValueError:
raise PageNotAnInteger
return self.validate_number(page_number)

def get_page(self, page_number):
try:
page_number = int(page_number) + 1
except ValueError:
raise PageNotAnInteger
return self.page(page_number).object_list

def has_next_page(self, page_number):
return page_number < self.pages - 1

def has_previous_page(self, page_number):
return page_number > 0

def first_on_page(self, page_number):
"""
Returns the 1-based index of the first object on the given page,
relative to total objects found (hits).
"""
page_number = self.validate_page_number(page_number)
return (self.num_per_page * (page_number - 1)) + 1

def last_on_page(self, page_number):
"""
Returns the 1-based index of the last object on the given page,
relative to total objects found (hits).
"""
page_number = self.validate_page_number(page_number)
if page_number == self.num_pages:
return self.count
return page_number * self.num_per_page

# The old API called it "hits" instead of "count".
hits = Paginator.count

# The old API called it "pages" instead of "num_pages".
pages = Paginator.num_pages
5 changes: 0 additions & 5 deletions django/db/models/fields/__init__.py
Expand Up @@ -22,7 +22,6 @@
from django.utils.text import capfirst
from django.utils.translation import ugettext_lazy, ugettext as _
from django.utils.encoding import smart_unicode, force_unicode, smart_str
from django.utils.maxlength import LegacyMaxlength
from django.utils import datetime_safe

class NOT_PROVIDED:
Expand Down Expand Up @@ -62,10 +61,6 @@ def manipulator_validator_unique(f, opts, self, field_data, all_data):
# getattr(obj, opts.pk.attname)

class Field(object):
# Provide backwards compatibility for the maxlength attribute and
# argument for this class and all subclasses.
__metaclass__ = LegacyMaxlength

# Designates whether empty strings fundamentally are allowed at the
# database level.
empty_strings_allowed = True
Expand Down
5 changes: 0 additions & 5 deletions django/db/models/fields/related.py
Expand Up @@ -626,11 +626,6 @@ def __init__(self, to, to_field=None, rel_class=ManyToOneRel, **kwargs):
to_field = to_field or to._meta.pk.name
kwargs['verbose_name'] = kwargs.get('verbose_name', None)

if 'edit_inline_type' in kwargs:
import warnings
warnings.warn("edit_inline_type is deprecated. Use edit_inline instead.", DeprecationWarning)
kwargs['edit_inline'] = kwargs.pop('edit_inline_type')

kwargs['rel'] = rel_class(to, to_field,
num_in_admin=kwargs.pop('num_in_admin', 3),
min_num_in_admin=kwargs.pop('min_num_in_admin', None),
Expand Down
5 changes: 1 addition & 4 deletions django/db/models/fields/subclassing.py
Expand Up @@ -5,9 +5,7 @@
to_python() and the other necessary methods and everything will work seamlessly.
"""

from django.utils.maxlength import LegacyMaxlength

class SubfieldBase(LegacyMaxlength):
class SubfieldBase(type):
"""
A metaclass for custom Field subclasses. This ensures the model's attribute
has the descriptor protocol attached to it.
Expand Down Expand Up @@ -50,4 +48,3 @@ def contribute_to_class(self, cls, name):
setattr(cls, self.name, Creator(self))

return contribute_to_class

16 changes: 0 additions & 16 deletions django/db/models/query.py
Expand Up @@ -757,22 +757,6 @@ def iterator(self):
yield iter([]).next()


# QOperator, QNot, QAnd and QOr are temporarily retained for backwards
# compatibility. All the old functionality is now part of the 'Q' class.
class QOperator(Q):
def __init__(self, *args, **kwargs):
warnings.warn('Use Q instead of QOr, QAnd or QOperation.',
DeprecationWarning, stacklevel=2)
super(QOperator, self).__init__(*args, **kwargs)

QOr = QAnd = QOperator


def QNot(q):
warnings.warn('Use ~q instead of QNot(q)', DeprecationWarning, stacklevel=2)
return ~q


def get_cached_row(klass, row, index_start, max_depth=0, cur_depth=0,
requested=None):
"""
Expand Down
4 changes: 0 additions & 4 deletions django/oldforms/__init__.py
Expand Up @@ -5,7 +5,6 @@
from django.conf import settings
from django.utils.translation import ugettext, ungettext
from django.utils.encoding import smart_unicode, force_unicode
from django.utils.maxlength import LegacyMaxlength

FORM_FIELD_ID_PREFIX = 'id_'

Expand Down Expand Up @@ -304,9 +303,6 @@ class FormField(object):
Subclasses should also implement a render(data) method, which is responsible
for rending the form field in XHTML.
"""
# Provide backwards compatibility for the maxlength attribute and
# argument for this class and all subclasses.
__metaclass__ = LegacyMaxlength

def __str__(self):
return unicode(self).encode('utf-8')
Expand Down
65 changes: 0 additions & 65 deletions django/utils/maxlength.py

This file was deleted.

13 changes: 0 additions & 13 deletions docs/cache.txt
Expand Up @@ -159,19 +159,6 @@ cache is multi-process and thread-safe. To use it, set ``CACHE_BACKEND`` to

CACHE_BACKEND = 'locmem:///'

Simple caching (for development)
--------------------------------

A simple, single-process memory cache is available as ``"simple:///"``. This
merely saves cached data in-process, which means it should only be used in
development or testing environments. For example::

CACHE_BACKEND = 'simple:///'

**New in Django development version:** This cache backend is deprecated and
will be removed in a future release. New code should use the ``locmem`` backend
instead.

Dummy caching (for development)
-------------------------------

Expand Down
4 changes: 0 additions & 4 deletions docs/model-api.txt
Expand Up @@ -144,10 +144,6 @@ The admin represents this as an ``<input type="text">`` (a single-line input).
(in characters) of the field. The max_length is enforced at the database level
and in Django's validation.

Django veterans: Note that the argument is now called ``max_length`` to
provide consistency throughout Django. There is full legacy support for
the old ``maxlength`` argument, but ``max_length`` is preferred.

``CommaSeparatedIntegerField``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
9 changes: 0 additions & 9 deletions docs/pagination.txt
Expand Up @@ -137,12 +137,3 @@ Attributes
``number`` -- The 1-based page number for this page.

``paginator`` -- The associated ``Paginator`` object.

The legacy ``ObjectPaginator`` class
====================================

The ``Paginator`` and ``Page`` classes are new in the Django development
version, as of revision 7306. In previous versions, Django provided an
``ObjectPaginator`` class that offered similar functionality but wasn't as
convenient. This class still exists, for backwards compatibility, but Django
now issues a ``DeprecationWarning`` if you try to use it.
8 changes: 4 additions & 4 deletions docs/sessions.txt
Expand Up @@ -65,10 +65,10 @@ you've configured your cache; see the `cache documentation`_ for details.
.. note::

You should probably only use cache-based sessions if you're using the
memcached cache backend. The local memory and simple cache backends
don't retain data long enough to be good choices, and it'll be faster
to use file or database sessions directly instead of sending everything
through the file or database cache backends.
Memcached cache backend. The local-memory cache backend doesn't retain data
long enough to be a good choice, and it'll be faster to use file or
database sessions directly instead of sending everything through the file
or database cache backends.

Using sessions in views
=======================
Expand Down

0 comments on commit 351a3ca

Please sign in to comment.