Tag Archives: gotchas

Network users and Mac 10.5 archive and install

When upgrading a Mac from Mac OS X 10.4 (Tiger) to 10.5 (Leopard), remember that network accounts are not included if you do an archive and install and choose to migrate existing users. If a network account had its home folder at /Users/jbloggs then it will have been moved to /Previous Systems.localized/2009-11-06_0346/Users/jbloggs (although the date portion will be the date that you did your install).

This applies to network accounts which authenticate against Active Directory and do not have a mobile account.

Why my place of work used to setup Macs with the option for create mobile account at login turned off is a mystery to me.

Old-style Python class system and parent methods

I rather like Python’s explicit object reference requirement, whereby method definitions for a class instance have to use self as the first parameter (I should write some classes that use this instead of self some time, just to annoy myself).

But I was tripped up debugging a problem that centred on a simple class I had that needed to do a bit of housekeeping for byte streams:

from StringIO import StringIO

class MyString(StringIO):
    def __init__(self, *args, **kwargs):
        self._customized = True # Or similar housekeeping
        super(MyString, self).__init__(*args, **kwargs)

Creating an object from this class raises a TypeError:

>>> s = MyString()
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 4, in __init__
TypeError: super() argument 1 must be type, not classobj

Wuh? I always used super like that before, and it always worked. But my mistake here was I was sub-classing an old-style class, and super only works with new-style classes.

The correct way of calling the parent method for old-style classes:

class MyString(StringIO):
    def __init__(self, *args, **kwargs):
        self._customized = True # Or similar housekeeping
        StringIO.__init__(self, *args, **kwargs)

That works! But the distinction between the two class models is so inelegant, so clunky. It is a nasty bit of Python’s historic implementation that one needs to keep in mind, and it is knowledge that makes me no cleverer (although it does mean I’m less stupid than I was).

Of course Python 3000 removes this distinction…