Back to index

plone3  3.1.7
two51_two52.py
Go to the documentation of this file.
00001 from Products.CMFPlone.migrations.v3_0.alphas import enableZope3Site
00002 from Products.CMFPlone.migrations.v3_0.alphas import registerToolsAsUtilities
00003 
00004 
00005 def two51_two52(portal):
00006     """2.5.1 -> 2.5.2
00007     """
00008     out = []
00009 
00010     # Make the portal a Zope3 site
00011     enableZope3Site(portal, out)
00012 
00013     # register some tools as utilities
00014     registerToolsAsUtilities(portal, out)
00015 
00016     # Make sure the cookie auth redirects to the correct location
00017     setLoginFormInCookieAuth(portal, out)
00018 
00019     return out
00020 
00021 
00022 def setLoginFormInCookieAuth(portal, out):
00023     """Makes sure the cookie auth redirects to 'require_login' instead
00024        of 'login_form'."""
00025     uf = portal._getOb('acl_users', None)
00026     if uf is None or getattr(uf.aq_base, '_getOb', None) is None:
00027         # we have no user folder or it's not a PAS folder, do nothing
00028         return
00029     cookie_auth = uf._getOb('credentials_cookie_auth', None)
00030     if cookie_auth is None:
00031         # there's no cookie auth object, do nothing
00032         return
00033     current_login_form = cookie_auth.getProperty('login_path')
00034     if current_login_form != 'login_form':
00035         # it's customized already, do nothing
00036         return
00037     cookie_auth.manage_changeProperties(login_path='require_login')
00038     out.append("Changed credentials_cookie_path login_path property "
00039                "to 'require_login'.")