'Insert a record in the database
Parameters can be positional or keyword arguments. If positional
they must be in the same order as in the create() method
If some of the fields are missing the value is set to None
Returns the record identifier'

def insert(self, *args, **kw):

    if args:
        kw = dict([(f, arg) for (f, arg) in zip(self.fields, args)])
    record = dict([(f, None) for f in self.fields])
    for key in kw:
        if (not (key in self.fields)):
            raise NameError(('Invalid    field    name    :    %s' % key))
    for (k, v) in kw.items():
        record[k] = v
    record['__id__'] = self.next_id
    record['__version__'] = 0
    self.records[self.next_id] = record
    for ix in self.indices.keys():
        bisect.insort(self.indices[ix].setdefault(record[ix], []), self.next_id)
    self.next_id += 1
    return record['__id__']
