| 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 |
__author__ = """Matt Dorn <matt_dorn@yahoo.com>""" |
|---|
| 26 |
__docformat__ = 'plaintext' |
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
import os.path |
|---|
| 30 |
import sys |
|---|
| 31 |
from StringIO import StringIO |
|---|
| 32 |
from sets import Set |
|---|
| 33 |
from App.Common import package_home |
|---|
| 34 |
from Products.CMFCore.utils import getToolByName |
|---|
| 35 |
from Products.CMFCore.utils import manage_addTool |
|---|
| 36 |
from Products.ExternalMethod.ExternalMethod import ExternalMethod |
|---|
| 37 |
from zExceptions import NotFound, BadRequest |
|---|
| 38 |
|
|---|
| 39 |
from Products.Archetypes.Extensions.utils import installTypes |
|---|
| 40 |
from Products.Archetypes.Extensions.utils import install_subskin |
|---|
| 41 |
from Products.Archetypes.config import TOOL_NAME as ARCHETYPETOOLNAME |
|---|
| 42 |
from Products.Archetypes.atapi import listTypes |
|---|
| 43 |
from Products.PloneXL8.config import PROJECTNAME |
|---|
| 44 |
from Products.PloneXL8.config import product_globals as GLOBALS |
|---|
| 45 |
|
|---|
| 46 |
def install(self): |
|---|
| 47 |
""" External Method to install PloneXL8 """ |
|---|
| 48 |
out = StringIO() |
|---|
| 49 |
print >> out, "Installation log of %s:" % PROJECTNAME |
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
try: |
|---|
| 55 |
from Products.PloneXL8.config import DEPENDENCIES |
|---|
| 56 |
except: |
|---|
| 57 |
DEPENDENCIES = [] |
|---|
| 58 |
portal = getToolByName(self,'portal_url').getPortalObject() |
|---|
| 59 |
quickinstaller = portal.portal_quickinstaller |
|---|
| 60 |
for dependency in DEPENDENCIES: |
|---|
| 61 |
print >> out, "Installing dependency %s:" % dependency |
|---|
| 62 |
quickinstaller.installProduct(dependency) |
|---|
| 63 |
get_transaction().commit(1) |
|---|
| 64 |
|
|---|
| 65 |
classes = listTypes(PROJECTNAME) |
|---|
| 66 |
installTypes(self, out, |
|---|
| 67 |
classes, |
|---|
| 68 |
PROJECTNAME) |
|---|
| 69 |
install_subskin(self, out, GLOBALS) |
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
|
|---|
| 75 |
|
|---|
| 76 |
try: |
|---|
| 77 |
installWorkflows = ExternalMethod('temp', |
|---|
| 78 |
'temp', |
|---|
| 79 |
PROJECTNAME+'.InstallWorkflows', |
|---|
| 80 |
'installWorkflows').__of__(self) |
|---|
| 81 |
except NotFound: |
|---|
| 82 |
installWorkflows = None |
|---|
| 83 |
|
|---|
| 84 |
if installWorkflows: |
|---|
| 85 |
print >>out,'Workflow Install:' |
|---|
| 86 |
res = installWorkflows(self,out) |
|---|
| 87 |
print >>out,res or 'no output' |
|---|
| 88 |
else: |
|---|
| 89 |
print >>out,'no workflow install' |
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 |
|
|---|
| 93 |
factory_tool = getToolByName(self,'portal_factory') |
|---|
| 94 |
factory_types=[ |
|---|
| 95 |
"TranslationCenter", |
|---|
| 96 |
"TranslationDoc", |
|---|
| 97 |
] + factory_tool.getFactoryTypes().keys() |
|---|
| 98 |
factory_tool.manage_setPortalFactoryTypes(listOfTypeIds=factory_types) |
|---|
| 99 |
|
|---|
| 100 |
from Products.PloneXL8.config import STYLESHEETS |
|---|
| 101 |
try: |
|---|
| 102 |
portal_css = getToolByName(portal, 'portal_css') |
|---|
| 103 |
for stylesheet in STYLESHEETS: |
|---|
| 104 |
try: |
|---|
| 105 |
portal_css.unregisterResource(stylesheet['id']) |
|---|
| 106 |
except: |
|---|
| 107 |
pass |
|---|
| 108 |
defaults = {'id': '', |
|---|
| 109 |
'media': 'all', |
|---|
| 110 |
'enabled': True} |
|---|
| 111 |
defaults.update(stylesheet) |
|---|
| 112 |
portal_css.manage_addStylesheet(**defaults) |
|---|
| 113 |
except: |
|---|
| 114 |
|
|---|
| 115 |
pass |
|---|
| 116 |
from Products.PloneXL8.config import JAVASCRIPTS |
|---|
| 117 |
try: |
|---|
| 118 |
portal_javascripts = getToolByName(portal, 'portal_javascripts') |
|---|
| 119 |
for javascript in JAVASCRIPTS: |
|---|
| 120 |
try: |
|---|
| 121 |
portal_javascripts.unregisterResource(javascript['id']) |
|---|
| 122 |
except: |
|---|
| 123 |
pass |
|---|
| 124 |
defaults = {'id': ''} |
|---|
| 125 |
defaults.update(javascript) |
|---|
| 126 |
portal_javascripts.registerScript(**defaults) |
|---|
| 127 |
except: |
|---|
| 128 |
|
|---|
| 129 |
pass |
|---|
| 130 |
|
|---|
| 131 |
|
|---|
| 132 |
|
|---|
| 133 |
try: |
|---|
| 134 |
install = ExternalMethod('temp', 'temp', |
|---|
| 135 |
PROJECTNAME+'.AppInstall', 'install') |
|---|
| 136 |
except NotFound: |
|---|
| 137 |
install = None |
|---|
| 138 |
|
|---|
| 139 |
if install: |
|---|
| 140 |
print >>out,'Custom Install:' |
|---|
| 141 |
res = install(self) |
|---|
| 142 |
if res: |
|---|
| 143 |
print >>out,res |
|---|
| 144 |
else: |
|---|
| 145 |
print >>out,'no output' |
|---|
| 146 |
else: |
|---|
| 147 |
print >>out,'no custom install' |
|---|
| 148 |
return out.getvalue() |
|---|
| 149 |
|
|---|
| 150 |
def uninstall(self): |
|---|
| 151 |
out = StringIO() |
|---|
| 152 |
|
|---|
| 153 |
|
|---|
| 154 |
|
|---|
| 155 |
try: |
|---|
| 156 |
uninstallWorkflows = ExternalMethod('temp', 'temp', |
|---|
| 157 |
PROJECTNAME+'.InstallWorkflows', |
|---|
| 158 |
'uninstallWorkflows').__of__(self) |
|---|
| 159 |
except NotFound: |
|---|
| 160 |
uninstallWorkflows = None |
|---|
| 161 |
|
|---|
| 162 |
if uninstallWorkflows: |
|---|
| 163 |
print >>out, 'Workflow Uninstall:' |
|---|
| 164 |
res = uninstallWorkflows(self, out) |
|---|
| 165 |
print >>out, res or 'no output' |
|---|
| 166 |
else: |
|---|
| 167 |
print >>out,'no workflow uninstall' |
|---|
| 168 |
|
|---|
| 169 |
|
|---|
| 170 |
|
|---|
| 171 |
try: |
|---|
| 172 |
uninstall = ExternalMethod('temp', 'temp', |
|---|
| 173 |
PROJECTNAME+'.AppInstall', 'uninstall') |
|---|
| 174 |
except: |
|---|
| 175 |
uninstall = None |
|---|
| 176 |
|
|---|
| 177 |
if uninstall: |
|---|
| 178 |
print >>out,'Custom Uninstall:' |
|---|
| 179 |
res = uninstall(self) |
|---|
| 180 |
if res: |
|---|
| 181 |
print >>out,res |
|---|
| 182 |
else: |
|---|
| 183 |
print >>out,'no output' |
|---|
| 184 |
else: |
|---|
| 185 |
print >>out,'no custom uninstall' |
|---|
| 186 |
|
|---|
| 187 |
return out.getvalue() |
|---|