#NEWLINE# def lock_for( self , user , hard_lock = False ) : #NEWLINE# #INDENT# "\n        Together with ``unlock_for`` this is probably the most important method \n        on this model. If applicable to your use-case, you should lock for a specific \n        user; that way, we can throw an exception when another user tries to unlock\n        an object they haven't locked themselves.\n        \n        When using soft locks (the default), any process can still use the save method\n        on this object. If you set ``hard_lock=True``, trying to save an object\n        without first unlocking will raise an ``ObjectLockedError``.\n        \n        Don't use hard locks unless you really need them. See :doc:`design`.\n        " #NEWLINE# logger . info ( ( 'Attempting to initiate a lock for user `%s`' % user ) ) #NEWLINE# if ( not isinstance ( user , auth . User ) ) : #NEWLINE# #INDENT# raise ValueError ( 'You should pass a valid auth.User to lock_for.' ) #NEWLINE# #UNINDENT# if self . lock_applies_to ( user ) : #NEWLINE# #INDENT# raise ObjectLockedError ( 'This object is already locked by another user.                 May not override, except through the `unlock` method.' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . _locked_at = datetime . today ( ) #NEWLINE# self . _locked_by = user #NEWLINE# self . _hard_lock = self . __init_hard_lock = hard_lock #NEWLINE# date = self . locked_at . strftime ( '%H:%M:%S' ) #NEWLINE# self . _state . locking = True #NEWLINE# logger . info ( ( 'Initiated a %s lock for `%s` at %s' % ( self . lock_type , self . locked_by , self . locked_at ) ) )