From 2bec6f7fec9a3c6dc446d10155f4e4b38fc7e995 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Tue, 23 Oct 2007 14:22:19 +0000
Subject: [PATCH] r16497 was bad, because it indexed a random Owner local roles
 from the acquisition context.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17133 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Catalog/CatalogTool.py |  5 -----
 product/ERP5Type/Base.py           | 15 +++++----------
 2 files changed, 5 insertions(+), 15 deletions(-)

diff --git a/product/ERP5Catalog/CatalogTool.py b/product/ERP5Catalog/CatalogTool.py
index 01ed7e4a13..f97dc8d707 100644
--- a/product/ERP5Catalog/CatalogTool.py
+++ b/product/ERP5Catalog/CatalogTool.py
@@ -161,13 +161,8 @@ class IndexableObjectWrapper(CMFCoreIndexableObjectWrapper):
                 allowed[user + ':' + role] = 1
               else:
                 allowed['user:' + user + ':' + role] = 1
-            elif 'Owner' in allowed:
-              ob._v_view_permission_owner = user
-
         if allowed.has_key('Owner'):
           del allowed['Owner']
-        else:
-          ob._v_view_permission_owner = None
         return list(allowed.keys())
 
 class RelatedBaseCategory(Method):
diff --git a/product/ERP5Type/Base.py b/product/ERP5Type/Base.py
index dab06775ce..4d99699a0f 100644
--- a/product/ERP5Type/Base.py
+++ b/product/ERP5Type/Base.py
@@ -1698,17 +1698,12 @@ class Base( CopyContainer,
   security.declareProtected( Permissions.AccessContentsInformation, 'getViewPermissionOwner' )
   def getViewPermissionOwner(self):
     """
-      Returns the user ID of the owner if Owner role
-      has View permission. Returns None else.
+      Returns the user ID of the owner if this user has View permission,
+      otherwise returns None.
     """
-    marker = []
-    if getattr(aq_base(self), '_v_view_permission_owner', marker) is not marker:
-      return self._v_view_permission_owner
-
-    path, user_id = self.getOwnerTuple()
-    if 'Owner' in rolesForPermissionOn(Permissions.View, self):
-      path, user_id = self.getOwnerTuple()
-      return user_id
+    owner = self.getWrappedOwner()
+    if owner is not None and owner.has_permission(Permissions.View, self):
+      return str(owner)
     return None
 
   # Private accessors for the implementation of relations based on
-- 
2.30.9