Reputation: 151
Events (and their business logic) are responsible for creating valid transactions. An Item's aggregate of Transactions determines how many of that item is currently on hand, etc.
In the world of Django (1.7), I have my row level access as model instance methods. Table level access as model Manager methods. Where shall I store my object creation logic, without leaking the domain into the view?
It feels weird creating transaction objects from the Event Manager, but appears to be the preferred way? Essentially, creating a method for each type of event?
Upvotes: 0
Views: 73
Reputation: 31940
You don't need to restrict yourself to models, managers, views or other tools framework provides. Sometimes plain function is what you are looking for.
I don't know anything about your event logic, but it seems something like this could do the trick:
def possibly_create_transaction(event):
if event.is_ok():
return Transaction()
Upvotes: 1