Commit bcb43861 authored by Vincent Pelletier's avatar Vincent Pelletier

ERP5{,Type}: Implement skinSuper at ERP5Site level.

Portal is the Skinnable object, skin magic belongs there.
parent b3fa0428
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
Portal class Portal class
""" """
import threading import thread, threading
from weakref import ref as weakref from weakref import ref as weakref
from OFS.Application import Application, AppInitializer from OFS.Application import Application, AppInitializer
from Products.ERP5Type import Globals from Products.ERP5Type import Globals
...@@ -33,6 +33,7 @@ from Products.ERP5Type.Accessor.Constant import PropertyGetter as ConstantGetter ...@@ -33,6 +33,7 @@ from Products.ERP5Type.Accessor.Constant import PropertyGetter as ConstantGetter
from Products.ERP5Type.Cache import caching_instance_method from Products.ERP5Type.Cache import caching_instance_method
from Products.ERP5Type.Cache import CachingMethod, CacheCookieMixin from Products.ERP5Type.Cache import CachingMethod, CacheCookieMixin
from Products.ERP5Type.ERP5Type import ERP5TypeInformation from Products.ERP5Type.ERP5Type import ERP5TypeInformation
from Products.ERP5Type.patches.CMFCoreSkinnable import SKINDATA, skinResolve
from Products.CMFActivity.Errors import ActivityPendingError from Products.CMFActivity.Errors import ActivityPendingError
import ERP5Defaults import ERP5Defaults
from Products.ERP5Type.TransactionalVariable import getTransactionalVariable from Products.ERP5Type.TransactionalVariable import getTransactionalVariable
...@@ -409,6 +410,20 @@ class ERP5Site(ResponseHeaderGenerator, FolderMixIn, CMFSite, CacheCookieMixin): ...@@ -409,6 +410,20 @@ class ERP5Site(ResponseHeaderGenerator, FolderMixIn, CMFSite, CacheCookieMixin):
return self return self
security.declareProtected(Permissions.AccessContentsInformation, 'skinSuper')
def skinSuper(self, skin, id):
if id[:1] != '_' and id[:3] != 'aq_':
skin_info = SKINDATA.get(thread.get_ident())
if skin_info is not None:
_, skin_selection_name, _, _ = skin_info
skin_value = skinResolve(self, (skin_selection_name, skin), id)
if skin_value is not None:
# Wrap at the portal to set the owner of the executing script.
# This mimics the usual way to get an object from skin folders,
# and it's required when 'skin_value' is a script with proxy roles.
return skin_value.__of__(self)
raise AttributeError(id)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'isDeletable') 'isDeletable')
def isDeletable(self, check_relation): def isDeletable(self, check_relation):
......
...@@ -61,7 +61,6 @@ from Products.ERP5Type import _dtmldir ...@@ -61,7 +61,6 @@ from Products.ERP5Type import _dtmldir
from Products.ERP5Type import PropertySheet from Products.ERP5Type import PropertySheet
from Products.ERP5Type import interfaces from Products.ERP5Type import interfaces
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from Products.ERP5Type.patches.CMFCoreSkinnable import SKINDATA, skinResolve
from Products.ERP5Type.Utils import UpperCase from Products.ERP5Type.Utils import UpperCase
from Products.ERP5Type.Utils import convertToUpperCase, convertToMixedCase from Products.ERP5Type.Utils import convertToUpperCase, convertToMixedCase
from Products.ERP5Type.Utils import createExpressionContext, simple_decorator from Products.ERP5Type.Utils import createExpressionContext, simple_decorator
...@@ -3086,18 +3085,7 @@ class Base( ...@@ -3086,18 +3085,7 @@ class Base(
security.declareProtected(Permissions.AccessContentsInformation, 'skinSuper') security.declareProtected(Permissions.AccessContentsInformation, 'skinSuper')
def skinSuper(self, skin, id): def skinSuper(self, skin, id):
if id[:1] != '_' and id[:3] != 'aq_': return self.getPortalObject().skinSuper(skin, id).__of__(self)
skin_info = SKINDATA.get(thread.get_ident())
if skin_info is not None:
portal = self.getPortalObject()
_, skin_selection_name, _, _ = skin_info
object = skinResolve(portal, (skin_selection_name, skin), id)
if object is not None:
# First wrap at the portal to set the owner of the executing script.
# This mimics the usual way to get an object from skin folders,
# and it's required when 'object' is an script with proxy roles.
return object.__of__(portal).__of__(self)
raise AttributeError(id)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'get_local_permissions') 'get_local_permissions')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment