def get_next_id(self):
        try:
            query = {'_id': 'last_id'}
            update = {'$inc': {'id': 1}}
            fn = self.db.internal.find_and_modify
            row = fn(query, update, upsert=True, new=True)
        except Exception as e:
            raise DatabaseException(e)
        return row['id']
def _getProvenance(self, item, user, version=None, resource='item',
                       checkOk=True):
        params = {}
        if version is not None:
            params = {'version': version}
        resp = self.request(
            path='/%s/%s/provenance' % (resource, item['_id']),
            method='GET', user=user, type='application/json', params=params)
        if checkOk:
            self.assertStatusOk(resp)
        return resp