[SQL-CVS] r1596 - SQLObject/trunk/sqlobject
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
|
From: <sub...@co...> - 2006-02-11 10:40:05
|
Author: ianb
Date: 2006-02-11 03:39:57 -0700 (Sat, 11 Feb 2006)
New Revision: 1596
Modified:
SQLObject/trunk/sqlobject/events.py
SQLObject/trunk/sqlobject/main.py
Log:
Applied SF [ 1423272 ] Events RowCreateSignal not really useful, added post-create from Rick Richardson
Modified: SQLObject/trunk/sqlobject/events.py
===================================================================
--- SQLObject/trunk/sqlobject/events.py 2006-02-11 10:37:34 UTC (rev 1595)
+++ SQLObject/trunk/sqlobject/events.py 2006-02-11 10:39:57 UTC (rev 1596)
@@ -79,7 +79,18 @@
Note: this is not called when an instance is created from an
existing database row.
"""
+class RowCreatedSignal(Signal):
+ """
+ Called after an instance is created, with the class as the
+ sender. Called with the arguments ``(kwargs, post_funcs)``.
+ There may be a ``connection`` argument. ``kwargs``may be usefully
+ modified. ``post_funcs`` is a list of callbacks, intended to have
+ functions appended to it, and are called with the arguments
+ ``(new_instance)``.
+ Note: this is not called when an instance is created from an
+ existing database row.
+ """
# @@: An event for getting a row? But for each row, when doing a
# select? For .sync, .syncUpdate, .expire?
Modified: SQLObject/trunk/sqlobject/main.py
===================================================================
--- SQLObject/trunk/sqlobject/main.py 2006-02-11 10:37:34 UTC (rev 1595)
+++ SQLObject/trunk/sqlobject/main.py 2006-02-11 10:39:57 UTC (rev 1596)
@@ -1273,7 +1273,11 @@
cache = self._connection.cache
cache.created(id, self.__class__, self)
self._init(id)
+ post_funcs = []
+ kw = dict([('class',self.__class__),('id',id)])
+ self.sqlmeta.send(events.RowCreatedSignal, kw, post_funcs)
+
def _SO_getID(self, obj):
return getID(obj)
|