From 67c801cd7320edc87d8950eaf1df39862c22e679 Mon Sep 17 00:00:00 2001
From: Kevin Deldycke <kevin@nexedi.com>
Date: Wed, 30 Aug 2006 14:15:06 +0000
Subject: [PATCH] Override PortalContent __call__ method to adapt behaviour for
 content called within a web site.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@9559 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Type/Base.py | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/product/ERP5Type/Base.py b/product/ERP5Type/Base.py
index 60535d1b70..188df7a1fd 100644
--- a/product/ERP5Type/Base.py
+++ b/product/ERP5Type/Base.py
@@ -326,6 +326,7 @@ def initializePortalTypeDynamicWorkflowMethods(self, klass, prop_holder):
                     method = WorkflowMethod(method, method_id)
                     setattr(prop_holder, method_id, method)
 
+
 class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ):
   """
     This is the base class for all ERP5 Zope objects.
@@ -382,6 +383,21 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ):
   # We want to use a default property view
   manage_propertiesForm = DTMLFile( 'dtml/properties', _dtmldir )
 
+  def __call__(self):
+    """
+      This method override PortalContent.__call__() method to get an altenate
+      default view if we have Web Site in the acquisition path.
+      If object is called within a Web Site object, try to use 'web_view' action
+      as default view. Else, use the default 'view' action as returned by the
+      default __call__ method of Portal Content objects.
+    """
+    rq = self.REQUEST
+    if hasattr(rq, 'web_site_value') and not (hasattr(rq, 'ignore_layout') or hasattr(rq, 'editable_mode')):
+      return _getViewFor(self, view='web_view')()
+    else:
+      call_method = getattr(PortalContent, '__call__', None)
+      return call_method(self)
+
   security.declareProtected( Permissions.ModifyPortalContent, 'setTitle' )
   def setTitle(self, value):
     """ sets the title. (and then reindexObject)"""
-- 
2.30.9