Hello,

you're try/except is handling both exceptions, SQL and your rise statement:

it should be something like:

class UniqueCourse(validators.FancyValidator):
    messages = {'unique': "A course by that name already exists"}

    def _to_python(self, name, state):
        try:
            Course.byName(name)
        except:
            raise validators.Invalid(self.message('unique',
state),name, state)
        return name


Regards

On 6/28/06, [EMAIL PROTECTED] < [EMAIL PROTECTED]> wrote:

I'm trying to write a really simple validator, but it's not working for
me. The raise Invalid never happens. What am I missing?

# relevant Import
from turbogears import controllers, widgets, validators, identity

#validator class
class UniqueCourse(validators.FancyValidator ):
    messages = {'unique': "A course by that name already exists"}

    def _to_python(self, name, state):
        try:
            Course.byName(name)
            raise validators.Invalid(self.message ('unique',
state),name, state)
        except:
            return name

This seems like it should be really really simple but I'm just smashing
my head on it. Any help would be appreciated.



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---

Reply via email to