[commits] r89 - selinux-site/trunk/selinux.theme/selinux/theme

tim at mail.se.linux.org tim at mail.se.linux.org
Fre Juli 27 21:24:29 CEST 2007


Author: tim
Date: 2007-07-27 21:24:28 +0200 (Fri, 27 Jul 2007)
New Revision: 89

Added:
   selinux-site/trunk/selinux.theme/selinux/theme/notifications.py
Modified:
   selinux-site/trunk/selinux.theme/selinux/theme/configure.zcml
Log:
Added event subscriber so irc can be notified about added objects.


Modified: selinux-site/trunk/selinux.theme/selinux/theme/configure.zcml
===================================================================
--- selinux-site/trunk/selinux.theme/selinux/theme/configure.zcml	2007-07-27 19:17:20 UTC (rev 88)
+++ selinux-site/trunk/selinux.theme/selinux/theme/configure.zcml	2007-07-27 19:24:28 UTC (rev 89)
@@ -37,4 +37,16 @@
       handler=".caching_subscribers.news_workflow_transition"
       />
 
+  <subscriber
+      for="Products.CMFCore.interfaces.IContentish
+           zope.app.container.interfaces.IObjectAddedEvent"
+      handler=".notifications.irc_object_added"
+      />
+
+  <subscriber
+      for="Products.CMFCore.interfaces.IContentish
+           Products.CMFCore.interfaces.IActionSucceededEvent"
+      handler=".notifications.irc_object_published"
+      />
+
 </configure>

Added: selinux-site/trunk/selinux.theme/selinux/theme/notifications.py
===================================================================
--- selinux-site/trunk/selinux.theme/selinux/theme/notifications.py	2007-07-27 19:17:20 UTC (rev 88)
+++ selinux-site/trunk/selinux.theme/selinux/theme/notifications.py	2007-07-27 19:24:28 UTC (rev 89)
@@ -0,0 +1,20 @@
+from xmlrpclib import Server
+from Products.CMFCore.utils import getToolByName
+from zope.i18n import translate
+from Products.CMFPlone.i18nl10n import utranslate
+
+def irc_object_added(obj, event):
+    workflow = getToolByName(obj, 'portal_workflow')
+    state = workflow.getInfoFor(obj, 'review_state')
+
+    # when a news item is created it's first added to a temporary folder
+    # that shouldn't trigger purge
+    if state == 'published' and obj.aq_parent.portal_type != 'TempFolder':
+        server = Server('http://localhost:7080')
+        obj_type = utranslate('plone', obj.portal_type,
+                         target_language='sv', context=obj)
+        msg = "%s (%s), %s" % (obj.Title(), obj_type, obj.absolute_url())
+        server.say('webb', msg)
+
+def irc_object_published(obj, event):
+    irc_object_added(obj, event)




More information about the commits mailing list