'A LayerMapping object is initialized using the given Model (not an instance),
a DataSource (or string path to an OGR-supported data file), and a mapping
dictionary.  See the module level docstring for more details and keyword
argument usage.'

def __init__(self, model, data, mapping, layer=0, source_srs=None, encoding=None, transaction_mode='commit_on_success', transform=True, unique=None, using=DEFAULT_DB_ALIAS):

    if isinstance(data, basestring):
        self.ds = DataSource(data)
    else:
        self.ds = data
    self.layer = self.ds[layer]
    self.using = using
    self.spatial_backend = connections[using].ops
    self.mapping = mapping
    self.model = model
    self.check_layer()
    if self.spatial_backend.mysql:
        transform = False
    else:
        self.geo_field = self.geometry_field()
    if transform:
        self.source_srs = self.check_srs(source_srs)
        self.transform = self.coord_transform()
    else:
        self.transform = transform
    if encoding:
        from codecs import lookup
        lookup(encoding)
        self.encoding = encoding
    else:
        self.encoding = None
    if unique:
        self.check_unique(unique)
        transaction_mode = 'autocommit'
        self.unique = unique
    else:
        self.unique = None
    if (transaction_mode in self.TRANSACTION_MODES):
        self.transaction_decorator = self.TRANSACTION_MODES[transaction_mode]
        self.transaction_mode = transaction_mode
    else:
        raise LayerMapError(('Unrecognized    transaction    mode:    %s' % transaction_mode))
    if (using is None):
        pass
