[ZPatterns] TransactionAgents question

John Eikenberry jae-zpat@kavi.com
Wed, 12 Dec 2001 13:47:03 -0800


A quick hack, but it shows the problem. The code in cause_error gets run
twice. This would succeed if it was pop'd from the queue when run the first
time.

    def testErrorRuleAgent(self):
        """This test that rule agents handle exceptions, and
           that they run in the order they were registered"""
        l=[]
        def cause_error(l=l):
            l.append('done2')
            raise "test"
        get_transaction().registerRule(
            lambda: l.append('done1'))
        get_transaction().registerRule(
            cause_error)
        try:
            get_transaction().commit(1)
        except "test": pass
        get_transaction().commit()
        assert l==['done1','done2']



Steve Alexander wrote:

> John Eikenberry wrote:
> 
> > 
> > The issue is that using ZedPatterns the above works, but the skinscript
> > stays in the queue and gets called again on the final commit. This looks to
> > be the result of TransactionAgent's method runRuleAgents(). Which runs all
> > the agents in its queue, removing them from the queue after they've run.
> > But if the agent raises an exception it never gets removed from the queue.
> 
> 
> From your description, that sounds like a bug rather than a feature.
> 
> 
> Can you tell me which of the TransactionAgents unit tests is testing the 
>   wrong behaviour, or, if they do not cover the problem you're having, 
> can you write an extra test or two that demonstrates the problem you're 
> having.
> 
> Thanks.
> 
> --
> Steve Alexander
> 
> 
> 
> _______________________________________________
> ZPatterns mailing list
> ZPatterns@eby-sarna.com
> http://www.eby-sarna.com/mailman/listinfo/zpatterns

-- 

John Eikenberry [jae@kavi.com]
______________________________________________________________
"A society that will trade a little liberty for a little order
 will deserve neither and lose both."
                                          --B. Franklin