Here's a clear example of the strange behaviour I'm observing.

    @turbogears.expose()
    def add(self):
        # The exception is being thrown during the next statement.
        self.form_widget = createReviewerForm()
        return DataController.add(self)

    @turbogears.expose()
    @turbogears.validate(form=createReviewerForm)
    def create(self, reviewer, writer, permission, tg_errors=None):
        if tg_errors:
            print tg_errors
            self.add()
        data = dict(reviewer=reviewer, writer=writer,
permission=permission)
        try:
            # Should throw an exception because of a unique constraint.
            DataController.create(self, **data)
        except Exception, e:
            print e
            # Please raise this exception.
            raise

I would expect this when create is called:
    ERROR:  duplicate key violates unique constraint
"reviewer_association_ui"
Which I saw in standard output because of "print e".

But instead TG raised this:
    ERROR:  current transaction is aborted, commands ignored until end
of transaction block

The only thing I can figure is that TG is calling the create method
twice.  If that's the case, why?  Why doesn't TG just throw the
exception when it runs into it?

Randall

Reply via email to