My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
BackwardsIncompatibleChanges  
Backwards-incompatible changes to Django MPTT since the 0.2 release.
Updated Dec 18, 2010 by craig.ds@gmail.com

This page is no longer maintained. Please see the upgrade notes in the documentation

HEAD - Backwards incompatible changes since 0.3.1 release

mptt.register() removed - replaced by abstract models

Old way to set up your models (0.3.1 and earlier):

import mptt
class MyModel(models.Model):
    ...
mptt.register(MyModel, order_insertion_by='name')

This has now been replaced with model inheritance, and the old keyword args are now specified on an inner MPTTMeta class:

from mptt.models import MPTTModel
class MyModel(MPTTModel):
    ...
    class MPTTMeta:
        order_insertion_by = 'name'

See the models documentation for more info.

0.3.0, 0.3.1 - Backwards incompatible changes since 0.2

order_insertion_by

NOTE This was undone in 0.3.1 - in 0.3.1 you can use either a tuple, a list or just a string.

The order_insertion_by argument to mptt.register must now be a list of field names.

Old format:

mptt.register(MyModel, order_insertion_by='name')

New format:

mptt.register(MyModel, order_insertion_by=['name'])
Comment by cardhuen...@gmail.com, Jul 16, 2008

Hello, I had to deploy my app on a python2.3 box. The only incompatibility I found was on the itertools.tee function on utils.py to which I copied down its implementation down on the code.

I suggest a django.utils.itercomp approach:

if hasattr(itertools, 'tee'):
  tee = itertools.tee
else:
  from mppt.itercompat import tee

The orginal itertools.tee() implementation, I believe:

class TeeData(object):
    """Holds cached values for TeeObjects"""
    def __init__(self, iterator):
        self.data = []
        self._iter = iterator

    def __getitem__(self, i):
        # iterates until 'i' if not done yet
        while i>= len(self.data):
            try:
                self.data.append( self._iter.next() )
            except AttributeError:
                # CPython raises a TypeError when next() is not defined
                raise TypeError('%s has no next() method' % self._iter)
        return self.data[i]


class TeeObject(object):
    """Iterables / Iterators as returned by the tee() function"""
    def __init__(self, iterable=None, tee_data=None):
        if tee_data:
            self.tee_data = tee_data
            self.pos = 0
        # <=> Copy constructor
        elif isinstance(iterable, TeeObject):
            self.tee_data = iterable.tee_data
            self.pos = iterable.pos
        else:
            self.tee_data = TeeData(iter(iterable))
            self.pos = 0
            
    def next(self):
        data = self.tee_data[self.pos]
        self.pos += 1
        return data
    
    def __iter__(self):
        return self

    
def tee(iterable, n=2):
    """Return n independent iterators from a single iterable.
    Note : once tee() has made a split, the original iterable
    should not be used anywhere else; otherwise, the iterable could get
    advanced without the tee objects being informed.
    
    Note : this member of the toolkit may require significant auxiliary
    storage (depending on how much temporary data needs to be stored).
    In general, if one iterator is going to use most or all of the
    data before the other iterator, it is faster to use list() instead
    of tee()
    
    Equivalent to :
    
    def tee(iterable, n=2):
        def gen(next, data={}, cnt=[0]):
            for i in count():
                if i == cnt[0]:
                    item = data[i] = next()
                    cnt[0] += 1
                else:
                    item = data.pop(i)
                yield item
        it = iter(iterable)
        return tuple([gen(it.next) for i in range(n)])
    """
    if isinstance(iterable, TeeObject):
        # a,b = tee(range(10)) ; c,d = tee(a) ; self.assert_(a is c)
        return tuple([iterable] +
        [TeeObject(tee_data=iterable.tee_data) for i in xrange(n-1)])
    tee_data = TeeData(iter(iterable))
    return tuple([TeeObject(tee_data=tee_data) for i in xrange(n)])
Powered by Google Project Hosting