#NEWLINE# @ expose ( '/edit/' , methods = ( 'GET' , 'POST' ) ) #NEWLINE# def edit_view( self ) : #NEWLINE# #INDENT# '\n            Edit model view\n        ' #NEWLINE# return_url = ( get_redirect_target ( ) or self . get_url ( '.index_view' ) ) #NEWLINE# if ( not self . can_edit ) : #NEWLINE# #INDENT# return redirect ( return_url ) #NEWLINE# #UNINDENT# id = get_mdict_item_or_list ( request . args , 'id' ) #NEWLINE# if ( id is None ) : #NEWLINE# #INDENT# return redirect ( return_url ) #NEWLINE# #UNINDENT# model = self . get_one ( id ) #NEWLINE# if ( model is None ) : #NEWLINE# #INDENT# flash ( gettext ( 'Record does not exist.' ) ) #NEWLINE# return redirect ( return_url ) #NEWLINE# #UNINDENT# form = self . edit_form ( obj = model ) #NEWLINE# if ( ( not hasattr ( form , '_validated_ruleset' ) ) or ( not form . _validated_ruleset ) ) : #NEWLINE# #INDENT# self . _validate_form_instance ( ruleset = self . _form_edit_rules , form = form ) #NEWLINE# #UNINDENT# if self . validate_form ( form ) : #NEWLINE# #INDENT# if self . update_model ( form , model ) : #NEWLINE# #INDENT# flash ( gettext ( 'Record was successfully saved.' ) ) #NEWLINE# if ( '_add_another' in request . form ) : #NEWLINE# #INDENT# return redirect ( self . get_url ( '.create_view' , url = return_url ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( '_continue_editing' in request . form ) : #NEWLINE# #INDENT# return redirect ( request . url ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return redirect ( self . get_save_return_url ( model , is_created = False ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if ( request . method == 'GET' ) : #NEWLINE# #INDENT# self . on_form_prefill ( form , id ) #NEWLINE# #UNINDENT# form_opts = FormOpts ( widget_args = self . form_widget_args , form_rules = self . _form_edit_rules ) #NEWLINE# if ( self . edit_modal and request . args . get ( 'modal' ) ) : #NEWLINE# #INDENT# template = self . edit_modal_template #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# template = self . edit_template #NEWLINE# #UNINDENT# return self . render ( template , model = model , form = form , form_opts = form_opts , return_url = return_url )