From dc608ebacc11c039c5cac005d01f4b5617dfd4e4 Mon Sep 17 00:00:00 2001
From: Yusei Tahara <yusei@nexedi.com>
Date: Thu, 27 Sep 2007 08:27:50 +0000
Subject: [PATCH] Added a monkey patch for pythonscript. if pythonscript has
 proxyrole, the icon will turns from green to red.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@16644 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Type/ZopePatch.py                 |   1 +
 product/ERP5Type/patches/PythonScript.py      |  42 ++++++++++++++++++
 .../ERP5Type/patches/pyscript_proxyrole.gif   | Bin 0 -> 236 bytes
 3 files changed, 43 insertions(+)
 create mode 100644 product/ERP5Type/patches/PythonScript.py
 create mode 100644 product/ERP5Type/patches/pyscript_proxyrole.gif

diff --git a/product/ERP5Type/ZopePatch.py b/product/ERP5Type/ZopePatch.py
index 79b2f97830..b5064e1a80 100644
--- a/product/ERP5Type/ZopePatch.py
+++ b/product/ERP5Type/ZopePatch.py
@@ -53,6 +53,7 @@ from Products.ERP5Type.patches import copy_reg_patch
 from Products.ERP5Type.patches import PersistencePatch
 from Products.ERP5Type.patches import PersistentMapping
 from Products.ERP5Type.patches import DateTimePatch
+from Products.ERP5Type.patches import PythonScript
 
 # for python2.3 compatibility
 import threading
diff --git a/product/ERP5Type/patches/PythonScript.py b/product/ERP5Type/patches/PythonScript.py
new file mode 100644
index 0000000000..64b080e7e9
--- /dev/null
+++ b/product/ERP5Type/patches/PythonScript.py
@@ -0,0 +1,42 @@
+##############################################################################
+#
+# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE
+#
+##############################################################################
+from Products.PythonScripts.PythonScript import PythonScript
+from OFS.misc_ import p_
+from App.ImageFile import ImageFile
+
+
+def haveProxyRole(self):
+  """if a script has proxy role, return True"""
+  if self._proxy_roles:
+    return True
+  return False
+
+
+def om_icons(self):
+  """Return a list of icon URLs to be displayed by an ObjectManager"""
+  icons = ({'path': 'misc_/PythonScripts/pyscript.gif',
+            'alt': self.meta_type, 'title': self.meta_type},)
+  if self.haveProxyRole():
+    icons = ({'path': 'p_/PythonScript_ProxyRole_icon',
+              'alt': 'Proxy Roled Python Script',
+              'title': 'This script has proxy role.'},)
+  return icons
+
+pyscript_proxyrole = ImageFile('pyscript_proxyrole.gif', globals())
+
+#
+# Add proxy role icon in ZMI
+#
+PythonScript.haveProxyRole = haveProxyRole
+PythonScript.om_icons = om_icons
+p_.PythonScript_ProxyRole_icon = pyscript_proxyrole
diff --git a/product/ERP5Type/patches/pyscript_proxyrole.gif b/product/ERP5Type/patches/pyscript_proxyrole.gif
new file mode 100644
index 0000000000000000000000000000000000000000..869de9b4bb062a132f9278b3973d6a4eb1eb00fe
GIT binary patch
literal 236
zcmZ?wbhEHb6krfwc+AJ3z`>!z!(+n7XU50pBO($YDw?ONT4QF`Y-iW$=GO1)J10JV
zM|=DJ$&>$sf#N?w=c3falGGH1^30M91$R&100zaMEQ|~c{0uq_KmanBfu-fcNk)f>
z7N-|7M71vC<rHFQox$tTEwaIar>k4yL{LUUuK^EpQs4=R7#`+^#0*iRX0{DU3=%vY
zO=$`Y5)z_rs~0FrNVIh=+^Uhn(GuDEP%DM2|6p=L!VU&jeggv`W_BJsZdPtx1|eoP
e9y>iYc4nXu8&7yRJM#i&N#<}-QD!MY25SJA=Rn~A

literal 0
HcmV?d00001

-- 
2.30.9