14 May 22:58
Re: Log changes to rows
From: Jim Steil <jim <at> qlf.com>
Subject: Re: Log changes to rows
Newsgroups: gmane.comp.python.sqlobject
Date: 2008-05-14 20:58:10 GMT
Subject: Re: Log changes to rows
Newsgroups: gmane.comp.python.sqlobject
Date: 2008-05-14 20:58:10 GMT
Oleg Broytmann wrote:
-Jim
On Wed, May 14, 2008 at 10:37:31AM -0500, Jim Steil wrote:Oleg: When I try this, I get a -- KeyError: 'class' -- exception. But, I then changed it to kw['sender'].sqlmeta.table and it works fine. Does that make any sense?Is there a way in the RowCreatedSignal event to capture the name of the object (table) that is being inserted into?[skip]I've been trying to get my logging working now for the RowCreatedSignal. I was having some issues with the kwargs parm. Instead of returning a dict with the values of my table, it is returning a dict with the class, and the keyfield value of the new record. Ex: {'class': <class 'motion.model.Contact'>, 'id': 11L}The table's name is kw['class'].sqlmeta.table.
-Jim
When I changed the event from RowCreatedSignal to RowCreateSignal, everything worked as expected, with the kwargs argument giving me the values of the new record. Ex: {'changedOn': datetime.datetime(2008, 5, 13, 16, 44, 57, 73000), 'county': '', 'distributor': None, 'city': '', 'district': 58, 'title': '', 'state': '', 'address1': '', 'email': '', 'fax': None, 'mobilePhone': None, 'companyName': '', 'phone2': None, 'phone3': None, 'address2': '', 'phone1': None, 'zipCode': '', 'hardcopyPriceLists': False, 'createdOn': datetime.datetime(2008, 5, 13, 16, 44, 57, 73000), 'pager': None, 'homePhone': None, 'firstName': u'Lou', 'lastName': u'Reichers', 'notes': None, 'customerNumber': None, 'coopId': None, 'emailPriceLists': False} I was expecting these two events to function the same. Is this a bug in the code, or something that I'm not understanding correctly?I think there is a misdesign. All signals should be sent 'self' as the first parameter (and proper keywords where apropriate). As this would be a major API change I can't just fix it in the current codebase. Will write a TODO entry for the trunk; the fix will be in 0.11. Oleg.
------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________ sqlobject-discuss mailing list sqlobject-discuss <at> lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
RSS Feed