'Creates a new object and locks it.
Similar to OpenWithLock below, this creates a locked object. The difference
is that when you call CreateWithLock, the object does not yet have to exist
in the data store.
Args:
urn: The object to create.
aff4_type: The desired type for this object.
token: The Security Token to use for opening this item.
age: The age policy used to build this object. Only makes sense when mode
has "r".
force_new_version: Forces the creation of a new object in the data_store.
blocking: When True, wait and repeatedly try to grab the lock.
blocking_lock_timeout: Maximum wait time when sync is True.
blocking_sleep_interval: Sleep time between lock grabbing attempts. Used
when blocking is True.
lease_time: Maximum time the object stays locked. Lock will be considered
released when this time expires.
Returns:
An AFF4 object of the desired type and mode.
Raises:
AttributeError: If the mode is invalid.'

def CreateWithLock(self, urn, aff4_type, token=None, age=NEWEST_TIME, force_new_version=True, blocking=True, blocking_lock_timeout=10, blocking_sleep_interval=1, lease_time=100):

    transaction = self._AcquireLock(urn, token=token, blocking=blocking, blocking_lock_timeout=blocking_lock_timeout, blocking_sleep_interval=blocking_sleep_interval, lease_time=lease_time)
    return self.Create(urn, aff4_type, mode='rw', token=token, age=age, force_new_version=force_new_version, transaction=transaction)
