1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
from Products.CMFPlone.Portal import listPolicies, custom_policies
from zLOG import INFO, ERROR
from SetupBase import SetupWidget
from types import StringType
from ZODB.POSException import ConflictError
import sys
import traceback
from Products.CMFPlone.utils import log_deprecated
log_deprecated("CustomizationPolicies are deprecated and will be removed in "
"Plone 3.0. Please use GenericSetup extension profiles instead.")
class CustomizationPolicySetup(SetupWidget):
type = 'Customization Policy Setup'
single = 1
description = """Sets up a customization policy, which configures
the plone setup. The default site has already been run.
<b>Please note</b> that uninstalling a policy is
<i>not</i> supported at this time.
Be careful before selecting this."""
def delItems(self, policy):
out = []
out.append(('Currently we have no way to remove '
'customisation policies', ERROR))
return out
def addItems(self, policy):
assert len(policy) == 1, "There must only be one policy set at a time."
out = []
c = custom_policies[policy[0]]
try:
res = c.customize(self.portal)
if res:
if isinstance(res, StringType):
for line in res.split('\n'):
out.append((line, INFO))
else:
out.extend(res)
out.append(("The customisation policy has been applied", INFO))
except ConflictError:
raise
except:
out.append(("An error has occured", INFO))
for line in traceback.format_tb(sys.exc_traceback):
out.append((line, ERROR))
return out
def installed(self):
return []
def available(self):
return listPolicies
|