[z3-checkins] r5591 - in z3/sqlos/trunk: . event

dreamcatcher at codespeak.net dreamcatcher at codespeak.net
Fri Jul 16 20:49:23 MEST 2004


Author: dreamcatcher
Date: Fri Jul 16 20:49:22 2004
New Revision: 5591

Added:
   z3/sqlos/trunk/event/
   z3/sqlos/trunk/event/__init__.py   (contents, props changed)
   z3/sqlos/trunk/event/configure.zcml
   z3/sqlos/trunk/event/subscriber.py   (contents, props changed)
Modified:
   z3/sqlos/trunk/configure.zcml
Log:
Add event subscriber to call syncUpdate.

Modified: z3/sqlos/trunk/configure.zcml
==============================================================================
--- z3/sqlos/trunk/configure.zcml	(original)
+++ z3/sqlos/trunk/configure.zcml	Fri Jul 16 20:49:22 2004
@@ -4,6 +4,7 @@
 
   <include file="permissions.zcml" />
   <include package=".auth" />
+  <include package=".event" />
 
   <browser:addMenuItem
       class="sqlos.container.SQLObjectContainer"

Added: z3/sqlos/trunk/event/__init__.py
==============================================================================
--- (empty file)
+++ z3/sqlos/trunk/event/__init__.py	Fri Jul 16 20:49:22 2004
@@ -0,0 +1,11 @@
+##############################################################################
+#
+# Copyright (c) 2004 Enfold Systems LLC. All rights reserved.
+#
+# This software is distributed under the terms of the Zope Public
+# License (ZPL) v2.1. See COPYING.txt for more information.
+#
+##############################################################################
+"""
+$Id: __init__.py 5475 2004-07-07 15:52:34Z dreamcatcher $
+"""

Added: z3/sqlos/trunk/event/configure.zcml
==============================================================================
--- (empty file)
+++ z3/sqlos/trunk/event/configure.zcml	Fri Jul 16 20:49:22 2004
@@ -0,0 +1,8 @@
+<configure xmlns="http://namespaces.zope.org/zope">
+
+  <subscriber
+      factory=".subscriber.sqlobjectModifiedSubscriber"
+      for="zope.app.event.interfaces.IObjectModifiedEvent"
+      />
+
+</configure>
\ No newline at end of file

Added: z3/sqlos/trunk/event/subscriber.py
==============================================================================
--- (empty file)
+++ z3/sqlos/trunk/event/subscriber.py	Fri Jul 16 20:49:22 2004
@@ -0,0 +1,28 @@
+##############################################################################
+#
+# Copyright (c) 2004 Enfold Systems LLC. All rights reserved.
+#
+# This software is distributed under the terms of the Zope Public
+# License (ZPL) v2.1. See COPYING.txt for more information.
+#
+##############################################################################
+"""
+$Id: __init__.py 5475 2004-07-07 15:52:34Z dreamcatcher $
+"""
+
+from sqlos.interfaces import ISQLObject
+
+def sqlobjectModifiedSubscriber(event):
+    obj = event.object
+    if not ISQLObject.providedBy(obj): return
+
+    # Send 'UPDATE' query, if not sent yet.
+    # If we don't do this, the cache will be cleared
+    # and if we try to re-fetch the object we will
+    # lose the new values.
+    obj.syncUpdate()
+
+    from sqlos.connection import connCache
+    for connection in connCache.values():
+        connection.cache.expire(obj.id, obj.__class__)
+


More information about the z3-checkins mailing list