Thanks for looking at it :)
The two methods just happened in the rush to cobble a test case
together for you ;) The version at the top was originally in DataStore,
and after moving it I'd forgotten to delete the second one in TestData
- D'OH :)
I'd originally got it to crash with loading twice also, but the load /
delete / save was the first test case that I ran which exhibited the
behavior, so that's the one I wrote about ;)
So your do_save now looks like:
def do_save (self, cursor):
map(lambda tmp: tmp.db_insert(cursor),
[tmp for tmp in self.test_data
if not hasattr(tmp, 'id') or not tmp.id])
map(lambda tmp: tmp.db_update(cursor),
[tmp for tmp in self.test_data
map(lambda tmp: tmp.db_delete(cursor), self.deleted_data)
#map(lambda tmp: tmp.removeObservers(), self.deleted_data)
self.deleted_data = 
and your __del__ like:
def __del__ (self):
Coz that still crashes for me if I load / delete / save :( Are you
using the SVN head or the 1.3b?
Here's the output:
me@... ~/projects/tmp/pyobjc/dirty >
(after either loading twice or the load / delete / save).
Also, if I try to override dealloc I get:
Resources/__boot__.py", line 45, in _run
execfile(path, globals(), globals())
File "/Users/clive/projects/tmp/pyobjc/dirty/DirtyApp.py", line 5, in
File "/Users/clive/projects/tmp/pyobjc/dirty/model.py", line 7, in ?
class TestData (NSObject):
objc.error: Cannot override method 'dealloc' from python
Instead of __del__ (which I commented out) I put:
def dealloc (self):
Is that indicative that we're using different versions of PyObjC?
Again, loads of thank for checking this out :)
On 6 Apr 2005, at 21:13, Ronald Oussoren wrote:
> On 6-apr-05, at 10:33, Clive Jevons wrote:
>> Right ... I've uploaded something which exhibits this behavior to:
>> The app is written against a MySQL 4.0 DB using MySQL-python-1.2.0
>> ... hope you've got those - if its a problem, let me know, and I'll
>> try and come up with something else ...
> I've installed both (the first using darwinport, the second using
> Bob's mpkg). I've tested using the stock Python in 10.3.8.
> Small examples using readily available opensource software should be
> fine. U
>> I'm using a self-compiled Python 2.4 and PyObjC 1.3b also compiled by
>> myself running on the latest and greatest 10.3.8.
>> Once untarred, change to the dirty directory (phwoar!) then:
>> $ mysql -u <user>
>> mysql > create database test_data;
>> mysql > quit
>> $ mysql -u <user> test_data < create_db.sql
>> Then start the app (you know better than I how to achieve this ;D),
>> then click load, then select an item, delete it, then save, then load
>> again - this should cause the Abort Trap (if you're running in 'debug
> I had to load twice, then the application hung.
>> You can then comment in line 130, and do the same again - should work
>> I've also tried a version where deleted data is not cached in an
>> array on the DataStore - but this leads to the same problem. In
>> TestData, you can also still see my attempt at the __del__ method.
>> Line 30 is commented out because once you comment in line 130 it will
>> cause a bus error (trying to remove observers twice).
> It did work for me if I enabled the removeObserver... call in __del__
> and added 'self.deleted_data = ' in do_save (after the call to
> db_delete). Remove the observer from 'self' instead of
> 'self.data_store' also works. You might be getting a crash because
> you're removing something that isn't an observer (either by removing
> an observer twice or by removeing the wrong observer).
> BTW. TestData defines two versions of observeValue..., the first copy
> is ignored.