Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

Commit

Permalink
Merge pull request #85 from postatum/103410068_update_events
Browse files Browse the repository at this point in the history
Update set_field_value usage docs
  • Loading branch information
jstoiko committed Oct 7, 2015
2 parents b69a61c + 9c7139c commit 5f727d2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/source/event_handlers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Before vs After
``Before`` events should be used to:
* Transform input
* Perform validation
* Apply changes to object that is being affected by the request using the ``event.set_field_value`` method
* Apply changes to object that is being affected by the request using the ``event.set_field_value`` method. Note that if field you change by calling ``event.set_field_value`` is not affected by request, it will be added to ``event.fields`` which will makes field processors which are connected to this field to be triggered, if they are run after this method call(connected to events after handler that performs method call).

``After`` events should be used to:
* Change DB objects which are not affected by the request
Expand Down
4 changes: 4 additions & 0 deletions docs/source/field_validators.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,7 @@ To edit other fields of instance, ``event.set_field_value`` method should be use
event = kwargs['event']
event.set_field_value('days_left', days_left)
return kwargs['new_value']
Note that if field you change by calling ``event.set_field_value`` is not affected by request, it will be added to ``event.fields`` which will makes field processors which are connected to changed field to be triggered, if they are run after this method call(connected to events after handler that performs method call).

E.g. if in addition to above ``calculate_days_left`` processor we had field processors for ``days_left`` field set up, running ``calculate_days_left`` will make ``days_left`` field processors run, because after ``event.set_field_value`` was called in ``calculate_days_left`` field ``days_left`` is considered "updated/changed".

0 comments on commit 5f727d2

Please sign in to comment.