[Grok-dev] unique item in container question
modiadi
adi at modiadi.com
Tue Mar 17 05:26:51 EDT 2009
Hello,
I have a grok.AddForm wich adds a NewsItem in a NewsContainer. I try
to write some kind of validation so I dont have duplicate news in the
container.
As I see I have 3 a few options:
1. Write an invariant in the NewsItem model where I check if the news
is unique in the *container*. I don't see this as a good option
because I have to explicitly refer to the container in side a model.
2. Write the validation in the Add grok.action. The idea is that just
before adding the new item in the container I check if I have
duplicates. This was easy to do.
My problem is that I can't(or I don't know how to) return an error to
the user from this place.
@grok.action('Add event')
def add(self,**data):
...... do some validation
return None?
Do you have any suggestions ?
Thank you !
More information about the Grok-dev
mailing list