...
 
Commits (8)
......@@ -2049,7 +2049,7 @@ class RegisteredSkinSelectionTemplateItem(BaseTemplateItem):
update_dict = kw.get('object_to_update')
force = kw.get('force')
portal = context.getPortalObject()
skin_tool = getToolByName(portal, 'portal_skins')
skin_tool = portal.portal_skins
for skin_folder_id in self._objects.keys():
......@@ -2091,7 +2091,7 @@ class RegisteredSkinSelectionTemplateItem(BaseTemplateItem):
def uninstall(self, context, **kw):
portal = context.getPortalObject()
skin_tool = getToolByName(portal, 'portal_skins')
skin_tool = portal.portal_skins
object_path = kw.get('object_path')
for skin_folder_id in (object_path,) if object_path else self._objects:
skin_selection_list = self._objects[skin_folder_id]
......
......@@ -322,7 +322,7 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
from Products.Localizer.MessageCatalog import (
message_catalog_alias_sources
)
sm = self.getSiteManager()
sm = self._components
for message_catalog in self.Localizer.objectValues():
sm.registerUtility(message_catalog,
provided=ITranslationDomain,
......@@ -332,21 +332,22 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
provided=ITranslationDomain,
name=alias)
def _doInitialSiteManagerMigration(self):
self._createInitialSiteManager()
# Now that we have a sitemanager, se can do things that require
# one. Including setting up ZTK style utilities and adapters. We
# can even call setSite(self), as long as we roll back that later,
# since we are actually in the middle of a setSite() call.
from zope.site.hooks import getSite, setSite
old_site = getSite()
try:
setSite(self)
# setSite(self) is not really necessary for the migration below, but
# could be needed by other migrations to be added here.
self._doTranslationDomainRegistration()
finally:
setSite(old_site)
def _registerMissingTools(self):
from Products.CMFCore import interfaces, utils
sm = self._components
# We don't want to register everything.
for tool_id in ("portal_skins", "portal_types", "portal_membership",
"portal_url", "portal_workflow",
# Registering portal_actions allows CMFDefault 2.3 to
# redirect correctly, cf UnauthorizedView.__call__
"portal_actions"):
tool = self.get(tool_id)
if tool is not None:
# Note: already registered tools will be either:
# - updated
# - registered again after being unregistered
sm.registerUtility(aq_base(tool),
utils._tool_interface_registry[tool_id])
# backward compatibility auto-migration
def getSiteManager(self):
......@@ -364,13 +365,25 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
# as cheap as it is on the case that self._components is already
# set.
_components = self._components
if _components is not None:
return _components
# This method below can take as (reasonably) long as it pleases
# since it will not be run ever again
self._doInitialSiteManagerMigration()
assert self._components is not None, 'Migration Failed!'
return self._components
if _components is None:
# only create _components
self._createInitialSiteManager()
_components = self._components
# Now that we have a sitemanager, se can do things that require
# one. Including setting up ZTK style utilities and adapters. We
# can even call setSite(self), as long as we roll back that later,
# since we are actually in the middle of a setSite() call.
from zope.site.hooks import getSite, setSite
old_site = getSite()
try:
setSite(self)
self._doTranslationDomainRegistration()
self._registerMissingTools()
finally:
setSite(old_site)
else:
self._registerMissingTools()
return _components
security.declareProtected(Permissions.View, 'view')
def view(self):
......
"Modified version for ERP5 to append the default action (/view) in the URL."
from Products.CMFCore.utils import getToolByName
ptool = getToolByName(script, 'portal_properties')
utool = getToolByName(script, 'portal_url')
portal = context.getPortalObject()
utool = portal.portal_url
portal_url = utool()
result = []
param = int(context.REQUEST.get('ignore_layout', 0)) and '?ignore_layout:int=1' or ''
param = '?ignore_layout:int=1' if int(portal.REQUEST.get('ignore_layout', 0)) else ''
if include_root:
result.append( { 'id' : 'root'
, 'title' : ptool.title()
, 'url' : '%s/view%s' % (portal_url, param)
}
)
relative = utool.getRelativeContentPath(context)
portal = utool.getPortalObject()
result = [{
'id' : 'root',
'title' : portal.portal_properties.title(),
'url' : '%s/view%s' % (portal_url, param),
}]
else:
result = []
obj = portal
now = []
for name in relative:
for name in utool.getRelativeContentPath(context):
obj = obj.restrictedTraverse(name)
now.append(name)
title = (
getattr(obj, "getCompactTranslatedTitle", lambda: None)() or
obj.getTitle() or obj.getId()
)
if not name == 'talkback':
if name != 'talkback':
result.append( { 'id' : name
, 'title' : title
, 'url' : '%s/%s/view%s' % (portal_url, '/'.join(now), param)
......
......@@ -33,6 +33,7 @@ import httplib
import urlparse
import base64
import urllib
import pkg_resources
from AccessControl.SecurityManagement import newSecurityManager
from Testing import ZopeTestCase
......@@ -640,7 +641,11 @@ class TestERP5Core(ERP5TypeTestCase, ZopeTestCase.Functional):
}
)
response = connection.getresponse()
self.assertEqual(response.status, 401)
if pkg_resources.get_distribution("Products.CMFCore").version < "2.3":
self.assertEqual(response.status, 401)
else:
self.assertEqual(response.status, 302)
self.assertIn("/login_form", response.getheader('location'))
self.assertEqual(response.getheader('WWW-Authenticate'), None)
def test_standardErrorMessageShouldNotRaiseUnauthorizeOnUnauthorizeDocument(self):
......@@ -667,7 +672,11 @@ class TestERP5Core(ERP5TypeTestCase, ZopeTestCase.Functional):
document_1.standard_error_message(error_type="MyErrorType", error_message="my error message.")
response = self.publish(document_1.getPath(), self.auth)
self.assertEqual(response.getStatus(), 401)
if pkg_resources.get_distribution("Products.CMFCore").version < "2.3":
self.assertEqual(response.getStatus(), 401)
else:
self.assertEqual(response.getStatus(), 302)
self.assertIn("/login_form", response.headers['location'])
self.assertNotIn("Also, the following error occurred", str(response))
def testCategoryExport(self):
......
......@@ -642,8 +642,6 @@ class TestProxyField(ERP5TypeTestCase):
ERP5Form('Base_viewProxyFieldLibrary', 'Proxys'))
self.container._setObject('Base_view',
ERP5Form('Base_view', 'View'))
from Products.CMFCore.tests.base.utils import _setUpDefaultTraversable
_setUpDefaultTraversable()
def addField(self, form, id, title, field_type):
......
......@@ -31,6 +31,7 @@
"""
import itertools
import pkg_resources
import transaction
import unittest
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
......@@ -1067,7 +1068,11 @@ class TestLocalRoleManagement(RoleManagementTestCase):
self.assertEqual(response.getStatus(), 200)
response = self.publish('/%s/first_last/getFirstName' % person_module_path,
basic='guest:guest')
self.assertEqual(response.getStatus(), 401)
if pkg_resources.get_distribution("Products.CMFCore").version < "2.3":
self.assertEqual(response.getStatus(), 401)
else:
self.assertEqual(response.getStatus(), 302)
self.assertIn("/login_form", response.headers['location'])
# Organisation does not have explicitly declared getTitle method in
# the class definition.
......@@ -1078,7 +1083,11 @@ class TestLocalRoleManagement(RoleManagementTestCase):
self.tic()
response = self.publish('/%s/my_company/getTitle' % self.getOrganisationModule().absolute_url(relative=1),
basic='guest:guest')
self.assertEqual(response.getStatus(), 401)
if pkg_resources.get_distribution("Products.CMFCore").version < "2.3":
self.assertEqual(response.getStatus(), 401)
else:
self.assertEqual(response.getStatus(), 302)
self.assertIn("/login_form", response.headers['location'])
class TestKeyAuthentication(RoleManagementTestCase):
......
......@@ -34,6 +34,7 @@ from Products.ERP5Type.patches import DCWorkflow
from Products.ERP5Type.patches import Worklists
from Products.ERP5Type.patches import BTreeFolder2
from Products.ERP5Type.patches import WorkflowTool
from Products.ERP5Type.patches import DynamicType
from Products.ERP5Type.patches import XMLExportImport
from Products.ERP5Type.patches import ppml
from Products.ERP5Type.patches import Expression
......
......@@ -141,11 +141,9 @@ def CMFCoreSkinnableSkinnableObjectManager_changeSkin(self, skinname, REQUEST=No
Patched not to call getSkin.
'''
if skinname is None:
sfn = self.getSkinsFolderName()
if sfn is not None:
sf = getattr(self, sfn, None)
if sf is not None:
skinname = sf.getDefaultSkin()
sf = getattr(self, "portal_skins", None)
if sf is not None:
skinname = sf.getDefaultSkin()
tid = get_ident()
SKINDATA[tid] = (
None,
......
......@@ -176,12 +176,21 @@ def modifyRequest(self, req, resp):
CookieCrumbler.modifyRequest = modifyRequest
def credentialsChanged(self, user, name, pw):
ac = standard_b64encode('%s:%s' % (name, pw))
method = self.getCookieMethod( 'setAuthCookie'
, self.defaultSetAuthCookie )
resp = self.REQUEST['RESPONSE']
method( resp, self.auth_cookie, quote( ac ) )
def credentialsChanged(self, user, name, pw, request=None):
"""
Updates cookie credentials if user details are changed.
"""
if request is None:
request = getRequest() # BBB for Membershiptool
reponse = request['RESPONSE']
# <patch>
# We don't want new lines, so use base64.standard_b64encode instead of
# base64.encodestring
ac = standard_b64encode('%s:%s' % (name, pw)).rstrip()
# </patch>
method = self.getCookieMethod('setAuthCookie',
self.defaultSetAuthCookie)
method(reponse, self.auth_cookie, quote(ac))
CookieCrumbler.credentialsChanged = credentialsChanged
......
##############################################################################
#
# Copyright (c) 2001 Zope Foundation and Contributors.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (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.CMFCore.DynamicType import DynamicType
def getTypeInfo(self):
""" Get the TypeInformation object specified by the portal type.
"""
# <patch>
tool = getattr(self.getPortalObject(), "portal_types", None)
# </patch>
if tool is None:
return None
return tool.getTypeInfo(self) # Can return None.
DynamicType.getTypeInfo = getTypeInfo
\ No newline at end of file
......@@ -979,4 +979,17 @@ def canDoActionFor(self, ob, action, wf_id=None, guard_kw={}):
WorkflowTool.canDoActionFor = canDoActionFor
security.declarePrivate('_listTypeInfo')
def _listTypeInfo(self):
""" List the portal types which are available.
"""
# <patch>
ttool = getattr(self.getPortalObject(), "portal_types", None)
# </patch>
if ttool is not None:
return ttool.listTypeInfo()
return ()
WorkflowTool._listTypeInfo = _listTypeInfo
InitializeClass(WorkflowTool)
......@@ -20,8 +20,7 @@ from OFS.DTMLMethod import DTMLMethod
from OFS.Folder import Folder
from AccessControl.User import UserFolder
from Products.CMFCore.CookieCrumbler \
import CookieCrumbler, manage_addCC, Redirect
from Products.CMFCore.CookieCrumbler import CookieCrumbler, manage_addCC
from Products.CMFCore.tests.test_CookieCrumbler import makerequest
from Products.CMFCore.tests.test_CookieCrumbler import CookieCrumblerTests
......