Thanks Phillip,<br><br>One silly question. Would it be possible to put a flag inside Trellis components that would allow to turn on some kind of debugging where if errors are thrown in rules they are made visible?<br>I was thinking about something like an optional debug decorator that gets thrown automatically around every rule if the debug flag is turned ON. <br>
<br>Thank you again for your quick answer. <br>Peter.<br><br><div class="gmail_quote">On Sat, Mar 22, 2008 at 6:48 PM, Phillip J. Eby <<a href="mailto:pje@telecommunity.com">pje@telecommunity.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">At 06:19 PM 3/22/2008 +0200, Peter Damoc wrote:<br>
>I've started getting this error:<br>
><br>
>AttributeError: Constants can't be changed<br>
>The problem is that I don't know what I'm doing wrong.<br>
>I used Trellis to manage some computations based on an external<br>
>object that contains a dictionary.<br>
>In a resync method I'm pushing the information inside a Trellis Dict object.<br>
>Everything worked fine till today when for some cases I get the above error.<br>
><br>
>How can I get more information about what my code is trying do to illegally?<br>
>How can I get the name of the constant that its trying to change?<br>
<br>
</div>Okay, here's what's happening. You're actually getting a different<br>
error in your application; this is just masking it, because it's an<br>
error that happens during the rollback caused by the first<br>
error. The specific issue is that an undo operation is adding a<br>
listener back to a cell that's become Constant, because it had no<br>
listeners. (What's weird about that is that the setting of the cell<br>
to Constant should have been undone before it got back to this point<br>
in the rollback. So something else weird is going on.)<br>
<div class="Ih2E3d"><br>
<br>
>here is a more complete trace:<br>
><br>
>File "c:\Projects\BPM\patient_display.py", line 133, in OnBiodynamic<br>
> dlg.panel.mp.resync(dlg.panel.meas)<br>
> File "<peak.events.trellis.wrap wrapping<br>
> modules.biodynamic.measurements.resync at 0x01CC97F0>", line 5, in resync<br>
> File<br>
> "c:\python25\lib\site-packages\Trellis-0.6a1-py2.5.egg\peak\events\stm.py",<br>
> line 466, in atomically<br>
> return super(Controller,self).atomically(self._process, func, args, kw)<br>
> File<br>
> "c:\python25\lib\site-packages\Trellis-0.6a1-py2.5.egg\peak\events\stm.py",<br>
> line 186, in atomically<br>
> self.cleanup(*sys.exc_info())<br>
> File<br>
> "c:\python25\lib\site-packages\Trellis-0.6a1-py2.5.egg\peak\events\stm.py",<br>
> line 309, in cleanup<br>
> return super(Controller, self).cleanup(*args)<br>
<br>
</div>If you use pdb.pm() to get into this traceback, and walk up to this<br>
stack frame, you should be able to look at 'args' to find out what<br>
the original exception was that started the problem. There really<br>
should be a better way to handle this, though.<br>
<br>
A possible workaround for the Constant part of the problem would be<br>
to ensure that any rule() in your application also has a value();<br>
that will ensure that the cell can never become constant (because<br>
it's writable). But I wouldn't try that unless the above doesn't<br>
resolve your issue.<br>
<br>
(It's too bad there's no way to link multiple exceptions together in<br>
Python right now, it'd sure come in handy here. That way, you could<br>
see the first exception as well as the cleanup exception.)<br>
<br>
</blockquote></div><br><br clear="all"><br>-- <br>There is NO FATE, we are the creators.