Triggers might work, if the only thing I wanted was the modification time.
But I want to be able to fill in things like the user as well.
Here's what I came up with...it seems to work well:
def m_update_listener(instance, kwargs, **kw):
kwargs['m_user_id'] = turbogears.identity.current.user.id
kwargs['m_time'] = datetime.datetime.utcnow()
sqlobject.events.listen(m_update_listener, PeopleRecord,
sqlobject.events.RowUpdateSignal)
The only issue is that I originally had the m_user_id as a foreign key to a
user table. I tried every combination I could think of to make this work,
but it always just left TurboGears in a paused state (no error messages...it
just didn't continue on after leaving the update_listener.)
I tried using m_user---I tried using m_user_id, I tried dropping the '.id'
on the right hand side...no dice!
Finally I got rid of the ForeignKey in my model (but kept it in the
database). Instead of a ForeignKey I used a simple IntCol---and success.
Thanks!
On Tue, Aug 26, 2008 at 3:46 AM, Andres Freund <[EMAIL PROTECTED]> wrote:
> Hi,
>
> On Sunday 17 August 2008, Sam's Lists wrote in "[SQLObject] Having a
> modified
> column filled in automagically...":
> > I'd like to be able to create a timestamp column called "mtime" in some
> of
> > my columns. This would hold a timestamp of when the row was last
> modified.
> Triggers on the database side?
>
> Andres
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> sqlobject-discuss mailing list
> sqlobject-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
>
>
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss