14 May 23:21
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 21:21:54 GMT
Subject: Re: Log changes to rows
Newsgroups: gmane.comp.python.sqlobject
Date: 2008-05-14 21:21:54 GMT
Oleg Broytmann wrote:
def addListener(newValues, postFunctions, tableName='', **kw):
try:
user = identity.current.user.id
except:
user = None
if tableName == '':
tableName = kw['sender'].sqlmeta.table
cl = ChangeLog(user=user,
tableName=tableName,
operation='INSERT',
columnName='All',
beforeImage='',
afterImage=str(newValues))
I added the tableName parameter for when I'm adding rows to the special table created for SQLRelatedJoins. When adding rows/removing rows to those tables, I'm manually calling this method to log my changes. This same method is called by the RowCreateSignal event.
-Jim
On Wed, May 14, 2008 at 03:58:10PM -0500, Jim Steil wrote:Let me elaborate a bit. Maybe some of the other stuff I've done has messed things up. Here is my full method:Oleg Broytmann wrote:No, I do not understand what is going on. There is the key 'class' in the dictionary. The word 'sender' is not mentioned in main.py (where the signal is sent). Oleg.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?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.
def addListener(newValues, postFunctions, tableName='', **kw):
try:
user = identity.current.user.id
except:
user = None
if tableName == '':
tableName = kw['sender'].sqlmeta.table
cl = ChangeLog(user=user,
tableName=tableName,
operation='INSERT',
columnName='All',
beforeImage='',
afterImage=str(newValues))
I added the tableName parameter for when I'm adding rows to the special table created for SQLRelatedJoins. When adding rows/removing rows to those tables, I'm manually calling this method to log my changes. This same method is called by the RowCreateSignal event.
-Jim
------------------------------------------------------------------------- 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