| 1 | ################################################################################
|
|---|
| 2 | # _confmanager.py
|
|---|
| 3 | #
|
|---|
| 4 | # This program is free software; you can redistribute it and/or
|
|---|
| 5 | # modify it under the terms of the GNU General Public License
|
|---|
| 6 | # as published by the Free Software Foundation; either version 2
|
|---|
| 7 | # of the License, or (at your option) any later version.
|
|---|
| 8 | #
|
|---|
| 9 | # This program is distributed in the hope that it will be useful,
|
|---|
| 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 12 | # GNU General Public License for more details.
|
|---|
| 13 | #
|
|---|
| 14 | # You should have received a copy of the GNU General Public License
|
|---|
| 15 | # along with this program; if not, write to the Free Software
|
|---|
| 16 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|---|
| 17 | ################################################################################
|
|---|
| 18 |
|
|---|
| 19 | # Imports.
|
|---|
| 20 | from cStringIO import StringIO
|
|---|
| 21 | from AccessControl import ClassSecurityInfo
|
|---|
| 22 | from App.Common import package_home
|
|---|
| 23 | from App.special_dtml import HTMLFile
|
|---|
| 24 | from DateTime.DateTime import DateTime
|
|---|
| 25 | from OFS.CopySupport import absattr
|
|---|
| 26 | from OFS.Image import Image
|
|---|
| 27 | from Products.PageTemplates import ZopePageTemplate
|
|---|
| 28 | from Products.PythonScripts import PythonScript
|
|---|
| 29 | import Globals
|
|---|
| 30 | import OFS.misc_
|
|---|
| 31 | import os
|
|---|
| 32 | import stat
|
|---|
| 33 | import urllib
|
|---|
| 34 | import zExceptions
|
|---|
| 35 | import zope.interface
|
|---|
| 36 | # Product imports.
|
|---|
| 37 | from IZMSConfigurationProvider import IZMSConfigurationProvider
|
|---|
| 38 | from IZMSNotificationService import IZMSNotificationService
|
|---|
| 39 | import IZMSMetamodelProvider, IZMSFormatProvider, IZMSSvnInterface
|
|---|
| 40 | import ZMSWorkflowProvider, ZMSWorkflowProviderAcquired
|
|---|
| 41 | import _globals
|
|---|
| 42 | import _fileutil
|
|---|
| 43 | import _filtermanager
|
|---|
| 44 | import _mediadb
|
|---|
| 45 | import _metacmdmanager
|
|---|
| 46 | import _multilangmanager
|
|---|
| 47 | import _sequence
|
|---|
| 48 | import zmslog
|
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 | """
|
|---|
| 52 | ################################################################################
|
|---|
| 53 | ###
|
|---|
| 54 | ### Initialization
|
|---|
| 55 | ###
|
|---|
| 56 | ################################################################################
|
|---|
| 57 | """
|
|---|
| 58 |
|
|---|
| 59 | # ------------------------------------------------------------------------------
|
|---|
| 60 | # _confmanager.initConf:
|
|---|
| 61 | # ------------------------------------------------------------------------------
|
|---|
| 62 | def initConf(self, profile, REQUEST):
|
|---|
| 63 | createIfNotExists = True
|
|---|
| 64 | files = self.getConfFiles()
|
|---|
| 65 | for filename in files.keys():
|
|---|
| 66 | label = files[filename]
|
|---|
| 67 | if label.startswith(profile + '.'):
|
|---|
| 68 | if filename.find('.zip') > 0:
|
|---|
| 69 | self.importConfPackage(filename,REQUEST,createIfNotExists)
|
|---|
| 70 | elif filename.find('.xml') > 0:
|
|---|
| 71 | self.importConf(filename,REQUEST,createIfNotExists)
|
|---|
| 72 | self.synchronizeObjAttrs()
|
|---|
| 73 |
|
|---|
| 74 |
|
|---|
| 75 | # ------------------------------------------------------------------------------
|
|---|
| 76 | # _confmanager.updateConf:
|
|---|
| 77 | # ------------------------------------------------------------------------------
|
|---|
| 78 | def updateConf(self, REQUEST):
|
|---|
| 79 | createIfNotExists = False
|
|---|
| 80 | filenames = self.getConfFiles().keys()
|
|---|
| 81 | for filename in filenames:
|
|---|
| 82 | self.importConf(filename,REQUEST,createIfNotExists)
|
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 | ################################################################################
|
|---|
| 86 | ################################################################################
|
|---|
| 87 | ###
|
|---|
| 88 | ### Class
|
|---|
| 89 | ###
|
|---|
| 90 | ################################################################################
|
|---|
| 91 | ################################################################################
|
|---|
| 92 | class ConfManager(
|
|---|
| 93 | _multilangmanager.MultiLanguageManager,
|
|---|
| 94 | _metacmdmanager.MetacmdManager,
|
|---|
| 95 | _filtermanager.FilterManager,
|
|---|
| 96 | ):
|
|---|
| 97 | zope.interface.implements(
|
|---|
| 98 | IZMSMetamodelProvider.IZMSMetamodelProvider,
|
|---|
| 99 | IZMSFormatProvider.IZMSFormatProvider,
|
|---|
| 100 | IZMSSvnInterface.IZMSSvnInterface)
|
|---|
| 101 |
|
|---|
| 102 | # Create a SecurityInfo for this class. We will use this
|
|---|
| 103 | # in the rest of our class definition to make security
|
|---|
| 104 | # assertions.
|
|---|
| 105 | security = ClassSecurityInfo()
|
|---|
| 106 |
|
|---|
| 107 | # Management Interface.
|
|---|
| 108 | # ---------------------
|
|---|
| 109 | manage_customize = HTMLFile('dtml/ZMS/manage_customize', globals())
|
|---|
| 110 | manage_customizeSvnForm = HTMLFile('dtml/ZMS/manage_customizesvnform', globals())
|
|---|
| 111 | manage_customizeDesignForm = HTMLFile('dtml/ZMS/manage_customizedesignform', globals())
|
|---|
| 112 |
|
|---|
| 113 |
|
|---|
| 114 | # --------------------------------------------------------------------------
|
|---|
| 115 | # ConfManager.importConfPackage:
|
|---|
| 116 | # --------------------------------------------------------------------------
|
|---|
| 117 | def importConfPackage(self, file, REQUEST, createIfNotExists=0):
|
|---|
| 118 | if type( file) is str:
|
|---|
| 119 | if file.startswith('http://'):
|
|---|
| 120 | file = StringIO( self.http_import(file))
|
|---|
| 121 | else:
|
|---|
| 122 | file = open(_fileutil.getOSPath(file),'rb')
|
|---|
| 123 | files = _fileutil.getZipArchive( file)
|
|---|
| 124 | for f in files:
|
|---|
| 125 | if not f.get('isdir'):
|
|---|
| 126 | self.importConf(f,REQUEST,createIfNotExists)
|
|---|
| 127 | self.synchronizeObjAttrs()
|
|---|
| 128 |
|
|---|
| 129 |
|
|---|
| 130 | # --------------------------------------------------------------------------
|
|---|
| 131 | # ConfManager.getConfXmlFile:
|
|---|
| 132 | # --------------------------------------------------------------------------
|
|---|
| 133 | def getConfXmlFile(self, file):
|
|---|
| 134 | if type(file) is dict:
|
|---|
| 135 | filename = file['filename']
|
|---|
| 136 | xmlfile = StringIO( file['data'])
|
|---|
| 137 | elif type(file) is str and file.startswith('http://'):
|
|---|
| 138 | filename = _fileutil.extractFilename(file)
|
|---|
| 139 | xmlfile = StringIO( self.http_import(file))
|
|---|
| 140 | else:
|
|---|
| 141 | filename = _fileutil.extractFilename(file)
|
|---|
| 142 | xmlfile = open(_fileutil.getOSPath(file),'rb')
|
|---|
| 143 | return filename, xmlfile
|
|---|
| 144 |
|
|---|
| 145 |
|
|---|
| 146 | # --------------------------------------------------------------------------
|
|---|
| 147 | # ConfManager.importConf:
|
|---|
| 148 | # --------------------------------------------------------------------------
|
|---|
| 149 | def importConf(self, file, REQUEST, createIfNotExists=0):
|
|---|
| 150 | message = ''
|
|---|
| 151 | filename, xmlfile = self.getConfXmlFile( file)
|
|---|
| 152 | zms_system = 1
|
|---|
| 153 | if filename.find('.charfmt.') > 0:
|
|---|
| 154 | self.format_manager.importCharformatXml(xmlfile, REQUEST, zms_system, createIfNotExists)
|
|---|
| 155 | elif filename.find('.filter.') > 0:
|
|---|
| 156 | _filtermanager.importXml(self, xmlfile, REQUEST, zms_system, createIfNotExists)
|
|---|
| 157 | elif filename.find('.metadict.') > 0:
|
|---|
| 158 | self.metaobj_manager.importMetadictXml(xmlfile, REQUEST, zms_system, createIfNotExists)
|
|---|
| 159 | elif filename.find('.metaobj.') > 0:
|
|---|
| 160 | self.metaobj_manager.importMetaobjXml(xmlfile, REQUEST, zms_system, createIfNotExists)
|
|---|
| 161 | elif filename.find('.metacmd.') > 0:
|
|---|
| 162 | _metacmdmanager.importXml(self, xmlfile, REQUEST, zms_system, createIfNotExists)
|
|---|
| 163 | elif filename.find('.langdict.') > 0:
|
|---|
| 164 | _multilangmanager.importXml(self, xmlfile, REQUEST, zms_system, createIfNotExists)
|
|---|
| 165 | elif filename.find('.textfmt.') > 0:
|
|---|
| 166 | self.format_manager.importTextformatXml(xmlfile, REQUEST, zms_system, createIfNotExists)
|
|---|
| 167 | xmlfile.close()
|
|---|
| 168 | return message
|
|---|
| 169 |
|
|---|
| 170 |
|
|---|
| 171 | # --------------------------------------------------------------------------
|
|---|
| 172 | # ConfManager.getConfFiles:
|
|---|
| 173 | #
|
|---|
| 174 | # Returns configuration-files from $ZMS_HOME/import-Folder
|
|---|
| 175 | # --------------------------------------------------------------------------
|
|---|
| 176 | def getConfFiles(self, pattern=None, REQUEST=None, RESPONSE=None):
|
|---|
| 177 | """
|
|---|
| 178 | ConfManager.getConfFiles
|
|---|
| 179 | """
|
|---|
| 180 | filenames = {}
|
|---|
| 181 | filepaths = [
|
|---|
| 182 | self.Control_Panel.getINSTANCE_HOME()+'/etc/zms/import/',
|
|---|
| 183 | package_home(globals())+'/import/',]
|
|---|
| 184 | try:
|
|---|
| 185 | conf = open( filepaths[0]+'configure.zcml','r')
|
|---|
| 186 | _globals.writeBlock( self, "[getConfFiles]: Read from "+filepaths[0]+"configure.zcml")
|
|---|
| 187 | except:
|
|---|
| 188 | conf = open( filepaths[1]+'configure.zcml','r')
|
|---|
| 189 | _globals.writeBlock( self, "[getConfFiles]: Read from "+filepaths[0]+"configure.zcml")
|
|---|
| 190 | conf_xml = self.xmlParse( conf)
|
|---|
| 191 | for source in self.xmlNodeSet(conf_xml,'source'):
|
|---|
| 192 | location = source['attrs']['location']
|
|---|
| 193 | if location.startswith('http://'):
|
|---|
| 194 | try:
|
|---|
| 195 | remote_conf = self.http_import(location+'configure.zcml')
|
|---|
| 196 | remote_conf_xml = self.xmlParse( remote_conf)
|
|---|
| 197 | for remote_file in self.xmlNodeSet(remote_conf_xml,'file'):
|
|---|
| 198 | filename = remote_file['attrs']['id']
|
|---|
| 199 | if filename not in filenames.keys():
|
|---|
| 200 | filenames[location+filename] = filename+' ('+remote_file['attrs']['title']+')'
|
|---|
| 201 | except:
|
|---|
| 202 | _globals.writeError( self, "[getConfFiles]: can't get conf-files from remote URL=%s"%location)
|
|---|
| 203 | else:
|
|---|
| 204 | for filepath in filepaths:
|
|---|
| 205 | if os.path.exists( filepath):
|
|---|
| 206 | for filename in os.listdir(filepath+location):
|
|---|
| 207 | path = filepath + filename
|
|---|
| 208 | mode = os.stat(path)[stat.ST_MODE]
|
|---|
| 209 | if not stat.S_ISDIR(mode):
|
|---|
| 210 | if filename not in filenames:
|
|---|
| 211 | filenames[path] = filename
|
|---|
| 212 | conf.close()
|
|---|
| 213 | # Filter.
|
|---|
| 214 | if pattern is not None:
|
|---|
| 215 | for k in filenames.keys():
|
|---|
| 216 | if k.find(pattern) < 0:
|
|---|
| 217 | del filenames[k]
|
|---|
| 218 | else:
|
|---|
| 219 | v = filenames[k]
|
|---|
| 220 | i = v.find(' ')
|
|---|
| 221 | if i < 0:
|
|---|
| 222 | i = len(v)
|
|---|
| 223 | v = v[:v.find(pattern)]+v[i:]
|
|---|
| 224 | filenames[k] = v
|
|---|
| 225 | # Return.
|
|---|
| 226 | if REQUEST is not None and \
|
|---|
| 227 | RESPONSE is not None:
|
|---|
| 228 | RESPONSE = REQUEST.RESPONSE
|
|---|
| 229 | content_type = 'text/xml; charset=utf-8'
|
|---|
| 230 | filename = 'getConfFiles.xml'
|
|---|
| 231 | RESPONSE.setHeader('Content-Type',content_type)
|
|---|
| 232 | RESPONSE.setHeader('Content-Disposition','inline;filename="%s"'%filename)
|
|---|
| 233 | RESPONSE.setHeader('Cache-Control', 'no-cache')
|
|---|
| 234 | RESPONSE.setHeader('Pragma', 'no-cache')
|
|---|
| 235 | return self.getXmlHeader() + self.toXmlString( filenames)
|
|---|
| 236 | else:
|
|---|
| 237 | return filenames
|
|---|
| 238 |
|
|---|
| 239 |
|
|---|
| 240 | """
|
|---|
| 241 | ############################################################################
|
|---|
| 242 | ###
|
|---|
| 243 | ### SVN
|
|---|
| 244 | ###
|
|---|
| 245 | ############################################################################
|
|---|
| 246 | """
|
|---|
| 247 |
|
|---|
| 248 | # --------------------------------------------------------------------------
|
|---|
| 249 | # ConfManager.svnCopy:
|
|---|
| 250 | # --------------------------------------------------------------------------
|
|---|
| 251 | def svnCopy(self, node, path, ids=[], excl_ids=[]):
|
|---|
| 252 | l = []
|
|---|
| 253 | for ob in node.objectValues(['ZMS']):
|
|---|
| 254 | # Add content-object artefacts to exclude-ids.
|
|---|
| 255 | for metaObjId in ob.getMetaobjIds():
|
|---|
| 256 | for metaObjAttrId in ob.getMetaobjAttrIds( metaObjId):
|
|---|
| 257 | metaObjAttr = ob.getMetaobjAttr(metaObjId,metaObjAttrId)
|
|---|
| 258 | if metaObjAttr['type'] in ob.metaobj_manager.valid_zopetypes:
|
|---|
| 259 | excl_ids.append( metaObjAttrId)
|
|---|
| 260 | obs = map( lambda x: (absattr(x.id), x), node.objectValues())
|
|---|
| 261 | obs.sort()
|
|---|
| 262 | for x in obs:
|
|---|
| 263 | id = x[0]
|
|---|
| 264 | ob = x[1]
|
|---|
| 265 | if id not in excl_ids and not id.startswith('A_'):
|
|---|
| 266 | action = None
|
|---|
| 267 | filepath = path+'/'+id
|
|---|
| 268 | filemtime = None
|
|---|
| 269 | mtime = long(ob.bobobase_modification_time().timeTime())
|
|---|
| 270 | meta_type = ob.meta_type
|
|---|
| 271 | if node.meta_type == 'Folder' and ob.meta_type in ['DTML Method','DTML Document','File','Image','Page Template','Script (Python)']:
|
|---|
| 272 | if ob.meta_type in ['DTML Method','DTML Document']:
|
|---|
| 273 | filepath += '.dtml'
|
|---|
| 274 | elif ob.meta_type in ['Page Template']:
|
|---|
| 275 | filepath += '.zpt'
|
|---|
| 276 | elif ob.meta_type in ['Script (Python)']:
|
|---|
| 277 | filepath += '.py'
|
|---|
| 278 | if os.path.exists( filepath):
|
|---|
| 279 | filestat = os.stat(filepath)
|
|---|
| 280 | filemtime = long(filestat[stat.ST_MTIME])
|
|---|
| 281 | if mtime > filemtime:
|
|---|
| 282 | action = 'refresh'
|
|---|
| 283 | elif mtime < filemtime:
|
|---|
| 284 | action = 'conflict'
|
|---|
| 285 | else:
|
|---|
| 286 | action = 'add'
|
|---|
| 287 | if action:
|
|---|
| 288 | l.append({'action':action,'filepath':filepath,'mtime':mtime,'filemtime':filemtime,'meta_type':meta_type})
|
|---|
| 289 | if filepath in ids or '*' in ids:
|
|---|
| 290 | _fileutil.exportObj(ob,filepath)
|
|---|
| 291 | atime = mtime
|
|---|
| 292 | times = (atime,mtime)
|
|---|
| 293 | os.utime(filepath,times)
|
|---|
| 294 | elif ob.meta_type == 'ZMS':
|
|---|
| 295 | l.extend( ob.metaobj_manager.svnCopy( node, path, ids))
|
|---|
| 296 | elif ob.meta_type == 'Folder':
|
|---|
| 297 | if not os.path.exists( filepath):
|
|---|
| 298 | action = 'add'
|
|---|
| 299 | l.append({'action':action,'filepath':filepath,'meta_type':meta_type})
|
|---|
| 300 | if filepath in ids or '*' in ids:
|
|---|
| 301 | _fileutil.mkDir(filepath)
|
|---|
| 302 | l.extend( self.svnCopy(ob,filepath,ids))
|
|---|
| 303 | return l
|
|---|
| 304 |
|
|---|
| 305 |
|
|---|
| 306 | # --------------------------------------------------------------------------
|
|---|
| 307 | # ConfManager.svnUpdate:
|
|---|
| 308 | # --------------------------------------------------------------------------
|
|---|
| 309 | def svnUpdate(self, node, path, ids=[], excl_ids=[]):
|
|---|
| 310 | l = []
|
|---|
| 311 | path_ids = []
|
|---|
| 312 | for filename in os.listdir(path):
|
|---|
| 313 | action = None
|
|---|
| 314 | id = filename
|
|---|
| 315 | filepath = path+'/'+id
|
|---|
| 316 | filestat = os.stat(filepath)
|
|---|
| 317 | mode = filestat[stat.ST_MODE]
|
|---|
| 318 | filemtime = long(filestat[stat.ST_MTIME])
|
|---|
| 319 | if id.endswith('.dtml'):
|
|---|
| 320 | id = id[:id.rfind('.')]
|
|---|
| 321 | elif id.endswith('.zpt'):
|
|---|
| 322 | id = id[:id.rfind('.')]
|
|---|
| 323 | elif id.endswith('.py'):
|
|---|
| 324 | id = id[:id.rfind('.')]
|
|---|
| 325 | path_ids.append( id)
|
|---|
| 326 | ob = getattr( node, id, None)
|
|---|
| 327 | if stat.S_ISDIR(mode):
|
|---|
| 328 | if filename == 'metaobj_manager':
|
|---|
| 329 | for ob in node.objectValues(['ZMS']):
|
|---|
| 330 | l.extend( ob.metaobj_manager.svnUpdate( node, filepath, ids))
|
|---|
| 331 | elif filename != '.svn':
|
|---|
| 332 | if ob is None:
|
|---|
| 333 | if filepath in ids or '*' in ids:
|
|---|
| 334 | node.manage_addFolder( id, 'New Folder')
|
|---|
| 335 | ob = getattr( node, id, None)
|
|---|
| 336 | meta_type = 'Folder'
|
|---|
| 337 | mtime = 0
|
|---|
| 338 | action = 'add'
|
|---|
| 339 | if action:
|
|---|
| 340 | l.append({'action':action,'filepath':filepath,'mtime':mtime,'filemtime':filemtime,'meta_type':meta_type})
|
|---|
| 341 | l.extend( self.svnUpdate(ob,filepath,ids))
|
|---|
| 342 | else:
|
|---|
| 343 | if ob is None:
|
|---|
| 344 | if filename.endswith('.dtml'):
|
|---|
| 345 | meta_type = 'DTML Method'
|
|---|
| 346 | if filepath in ids or '*' in ids:
|
|---|
| 347 | node.manage_addDTMLMethod( id=id, title='New DTML Method')
|
|---|
| 348 | elif filename.endswith('.zpt'):
|
|---|
| 349 | meta_type = 'Page Template'
|
|---|
| 350 | if filepath in ids or '*' in ids:
|
|---|
| 351 | node.manage_addProduct['PageTemplates'].manage_addPageTemplate(id=id,title='New Page Template')
|
|---|
| 352 | elif filename.endswith('.py'):
|
|---|
| 353 | meta_type = 'Script (Python)'
|
|---|
| 354 | if filepath in ids or '*' in ids:
|
|---|
| 355 | PythonScript.manage_addPythonScript( node, id)
|
|---|
| 356 | elif filename.lower().endswith('.gif') or \
|
|---|
| 357 | filename.lower().endswith('.jpg') or \
|
|---|
| 358 | filename.lower().endswith('.png'):
|
|---|
| 359 | meta_type = 'Image'
|
|---|
| 360 | if filepath in ids or '*' in ids:
|
|---|
| 361 | node.manage_addImage( id=id, file='', title='')
|
|---|
| 362 | else:
|
|---|
| 363 | meta_type = 'File'
|
|---|
| 364 | if filepath in ids or '*' in ids:
|
|---|
| 365 | node.manage_addFile( id=id, file='', title='')
|
|---|
| 366 | ob = getattr( node, id, None)
|
|---|
| 367 | mtime = 0
|
|---|
| 368 | action = 'add'
|
|---|
| 369 | else:
|
|---|
| 370 | meta_type = ob.meta_type
|
|---|
| 371 | # modification-time
|
|---|
| 372 | mtime = long(ob.bobobase_modification_time().timeTime())
|
|---|
| 373 | if mtime < filemtime:
|
|---|
| 374 | action = 'refresh'
|
|---|
| 375 | if action:
|
|---|
| 376 | l.append({'action':action,'filepath':filepath,'mtime':mtime,'filemtime':filemtime,'meta_type':meta_type})
|
|---|
| 377 | if filepath in ids or '*' in ids:
|
|---|
| 378 | file = open(filepath)
|
|---|
| 379 | data = file.read()
|
|---|
| 380 | if ob.meta_type == 'Page Template':
|
|---|
| 381 | ob.pt_edit(data,content_type='text/html')
|
|---|
| 382 | else:
|
|---|
| 383 | ob.manage_upload(data)
|
|---|
| 384 | file.close()
|
|---|
| 385 | if node is not None and node.meta_type != 'ZMS':
|
|---|
| 386 | for ob in node.objectValues(['ZMS']):
|
|---|
| 387 | # Add content-object artefacts to exclude-ids.
|
|---|
| 388 | for metaObjId in ob.getMetaobjIds():
|
|---|
| 389 | for metaObjAttrId in ob.getMetaobjAttrIds( metaObjId):
|
|---|
| 390 | metaObjAttr = ob.getMetaobjAttr(metaObjId,metaObjAttrId)
|
|---|
| 391 | if metaObjAttr['type'] in ob.metaobj_manager.valid_zopetypes:
|
|---|
| 392 | excl_ids.append( metaObjAttrId)
|
|---|
| 393 | for id in filter( lambda x: x not in path_ids and x not in excl_ids and not x.startswith('A_'), node.objectIds(['DTML Method','File','Folder','Image'])):
|
|---|
| 394 | ob = getattr( node, id)
|
|---|
| 395 | action = 'delete'
|
|---|
| 396 | filepath = path+'/'+id
|
|---|
| 397 | mtime = long(ob.bobobase_modification_time().timeTime())
|
|---|
| 398 | filemtime = 0
|
|---|
| 399 | meta_type = ob.meta_type
|
|---|
| 400 | l.append({'action':action,'filepath':filepath,'mtime':mtime,'filemtime':filemtime,'meta_type':meta_type})
|
|---|
| 401 | if filepath in ids or '*' in ids:
|
|---|
| 402 | node.manage_delObjects( ids=[id])
|
|---|
| 403 | return l
|
|---|
| 404 |
|
|---|
| 405 |
|
|---|
| 406 | """
|
|---|
| 407 | ############################################################################
|
|---|
| 408 | ###
|
|---|
| 409 | ### Configuration-Properties Getters
|
|---|
| 410 | ###
|
|---|
| 411 | ############################################################################
|
|---|
| 412 | """
|
|---|
| 413 |
|
|---|
| 414 | # --------------------------------------------------------------------------
|
|---|
| 415 | # ConfManager.getSequence:
|
|---|
| 416 | #
|
|---|
| 417 | # Returns sequence.
|
|---|
| 418 | # --------------------------------------------------------------------------
|
|---|
| 419 | def getSequence(self):
|
|---|
| 420 | id = 'acl_sequence'
|
|---|
| 421 | exists = id in self.objectIds(['Sequence'])
|
|---|
| 422 | portalMaster = self.getPortalMaster()
|
|---|
| 423 | if portalMaster is not None:
|
|---|
| 424 | startvalue = 0
|
|---|
| 425 | if exists:
|
|---|
| 426 | ob = getattr(self,id)
|
|---|
| 427 | startvalue = ob.value
|
|---|
| 428 | self.manage_delObjects(ids=[id])
|
|---|
| 429 | ob = portalMaster.getSequence()
|
|---|
| 430 | if ob.value < startvalue:
|
|---|
| 431 | ob.value = startvalue
|
|---|
| 432 | else:
|
|---|
| 433 | if not exists:
|
|---|
| 434 | sequence = _sequence.Sequence()
|
|---|
| 435 | self._setObject(sequence.id, sequence)
|
|---|
| 436 | ob = getattr(self,id)
|
|---|
| 437 | return ob
|
|---|
| 438 |
|
|---|
| 439 | # --------------------------------------------------------------------------
|
|---|
| 440 | # ConfManager.getMediaDb:
|
|---|
| 441 | #
|
|---|
| 442 | # Returns mediadb.
|
|---|
| 443 | # --------------------------------------------------------------------------
|
|---|
| 444 | def getMediaDb(self):
|
|---|
| 445 | for ob in self.getDocumentElement().objectValues(['MediaDb']):
|
|---|
| 446 | return ob
|
|---|
| 447 | return None
|
|---|
| 448 |
|
|---|
| 449 |
|
|---|
| 450 |
|
|---|
| 451 | # --------------------------------------------------------------------------
|
|---|
| 452 | # ConfManager.getResourceFolders:
|
|---|
| 453 | #
|
|---|
| 454 | # Returns list of resource-folders.
|
|---|
| 455 | # --------------------------------------------------------------------------
|
|---|
| 456 | def getResourceFolders(self):
|
|---|
| 457 | obs = []
|
|---|
| 458 | ids = self.getConfProperty('ZMS.resourceFolders','instance,common').split(',')
|
|---|
| 459 | if '*' in ids:
|
|---|
| 460 | ids.extend( map(lambda x: x.id, filter(lambda x: x.id not in ids, self.getHome().objectValues(['Folder']))))
|
|---|
| 461 | for id in ids:
|
|---|
| 462 | if id == '*':
|
|---|
| 463 | obs.append(self.getHome())
|
|---|
| 464 | else:
|
|---|
| 465 | container = getattr( self, id, None)
|
|---|
| 466 | if container is not None and len(container.objectValues(['ZMS']))==0:
|
|---|
| 467 | obs.append(container)
|
|---|
| 468 | return obs
|
|---|
| 469 |
|
|---|
| 470 |
|
|---|
| 471 | # --------------------------------------------------------------------------
|
|---|
| 472 | # ConfManager.getStylesheet:
|
|---|
| 473 | #
|
|---|
| 474 | # Returns stylesheet.
|
|---|
| 475 | # --------------------------------------------------------------------------
|
|---|
| 476 | def getStylesheet(self, id=None):
|
|---|
| 477 | stylesheets = self.getStylesheets()
|
|---|
| 478 | if id is None:
|
|---|
| 479 | return stylesheets[0]
|
|---|
| 480 | else:
|
|---|
| 481 | for css in stylesheets:
|
|---|
| 482 | if absattr( css.id) == id:
|
|---|
| 483 | return css
|
|---|
| 484 |
|
|---|
| 485 | # --------------------------------------------------------------------------
|
|---|
| 486 | # ConfManager.getStylesheets:
|
|---|
| 487 | #
|
|---|
| 488 | # Returns list of stylesheets.
|
|---|
| 489 | # --------------------------------------------------------------------------
|
|---|
| 490 | def getStylesheets(self):
|
|---|
| 491 | ids = []
|
|---|
| 492 | obs = []
|
|---|
| 493 | for container in self.getResourceFolders():
|
|---|
| 494 | for folder in [ getattr( container, 'css', None), container]:
|
|---|
| 495 | if folder is not None:
|
|---|
| 496 | for ob in folder.objectValues(['DTML Method', 'DTML Document', 'File']):
|
|---|
| 497 | id = absattr( ob.id)
|
|---|
| 498 | path = ob.getPhysicalPath()
|
|---|
| 499 | if len(filter(lambda x: x.endswith('css'), path)) > 0 and id not in ids:
|
|---|
| 500 | ids.append( id)
|
|---|
| 501 | if id == self.getConfProperty('ZMS.stylesheet','style.css'):
|
|---|
| 502 | obs.insert( 0, ob)
|
|---|
| 503 | else:
|
|---|
| 504 | obs.append( ob)
|
|---|
| 505 | return obs
|
|---|
| 506 |
|
|---|
| 507 |
|
|---|
| 508 | """
|
|---|
| 509 | ############################################################################
|
|---|
| 510 | ###
|
|---|
| 511 | ### Configuration-Tab Options
|
|---|
| 512 | ###
|
|---|
| 513 | ############################################################################
|
|---|
| 514 | """
|
|---|
| 515 |
|
|---|
| 516 | # --------------------------------------------------------------------------
|
|---|
| 517 | # ConfManager.customize_manage_options:
|
|---|
| 518 | # --------------------------------------------------------------------------
|
|---|
| 519 | def customize_manage_options(self):
|
|---|
| 520 | l = []
|
|---|
| 521 | l.append({'label':'TAB_SYSTEM','action':'manage_customize'})
|
|---|
| 522 | l.append({'label':'TAB_LANGUAGES','action':'manage_customizeLanguagesForm'})
|
|---|
| 523 | for ob in self.objectValues():
|
|---|
| 524 | if IZMSConfigurationProvider in list(zope.interface.providedBy(ob)):
|
|---|
| 525 | for d in ob.manage_sub_options():
|
|---|
| 526 | l.append(self.operator_setitem(d.copy(),'action',ob.id+'/'+d['action']))
|
|---|
| 527 | l.append({'label':'TAB_METACMD','action':'manage_customizeMetacmdForm'})
|
|---|
| 528 | l.append({'label':'TAB_FILTER','action':'manage_customizeFilterForm'})
|
|---|
| 529 | l.append({'label':'TAB_DESIGN','action':'manage_customizeDesignForm'})
|
|---|
| 530 | return l
|
|---|
| 531 |
|
|---|
| 532 |
|
|---|
| 533 | ############################################################################
|
|---|
| 534 | ###
|
|---|
| 535 | ### Configuration-Properties
|
|---|
| 536 | ###
|
|---|
| 537 | ############################################################################
|
|---|
| 538 |
|
|---|
| 539 | """
|
|---|
| 540 | Returns configuration-manager.
|
|---|
| 541 | """
|
|---|
| 542 | def getConfManager(self):
|
|---|
| 543 | return self
|
|---|
| 544 |
|
|---|
| 545 |
|
|---|
| 546 | """
|
|---|
| 547 | Returns property from configuration.
|
|---|
| 548 | @rtype: C{dict}
|
|---|
| 549 | """
|
|---|
| 550 | def getConfProperties(self):
|
|---|
| 551 | return getattr( self, '__attr_conf_dict__', {})
|
|---|
| 552 |
|
|---|
| 553 |
|
|---|
| 554 | """
|
|---|
| 555 | Removes property from configuration.
|
|---|
| 556 |
|
|---|
| 557 | @param key: The key.
|
|---|
| 558 | @type key: C{string}
|
|---|
| 559 | @return None
|
|---|
| 560 | """
|
|---|
| 561 | security.declareProtected('ZMS Administrator', 'delConfProperty')
|
|---|
| 562 | def delConfProperty(self, key):
|
|---|
| 563 | self.setConfProperty(key,None)
|
|---|
| 564 |
|
|---|
| 565 |
|
|---|
| 566 | """
|
|---|
| 567 | Returns property from configuration.
|
|---|
| 568 |
|
|---|
| 569 | @param key: The key.
|
|---|
| 570 | @type key: C{string}
|
|---|
| 571 | @param default: The default-value.
|
|---|
| 572 | @type default: C{any}
|
|---|
| 573 | @rtype: C{any}
|
|---|
| 574 | """
|
|---|
| 575 | def getConfProperty(self, key, default=None, REQUEST=None):
|
|---|
| 576 | """ ConfManager.getConfProperty """
|
|---|
| 577 | if REQUEST is not None:
|
|---|
| 578 | authorized = REQUEST['AUTHENTICATED_USER'].has_role('Authenticated')
|
|---|
| 579 | if not authorized:
|
|---|
| 580 | raise zExceptions.Unauthorized
|
|---|
| 581 | if OFS.misc_.misc_.zms['confdict'].has_key(key):
|
|---|
| 582 | default = OFS.misc_.misc_.zms['confdict'].get(key)
|
|---|
| 583 | return self.getConfProperties().get( key, default)
|
|---|
| 584 |
|
|---|
| 585 |
|
|---|
| 586 | """
|
|---|
| 587 | Sets property into configuration.
|
|---|
| 588 |
|
|---|
| 589 | @param key: The key.
|
|---|
| 590 | @type key: C{string}
|
|---|
| 591 | @param value: The value.
|
|---|
| 592 | @type value: C{any}
|
|---|
| 593 | @return None
|
|---|
| 594 | """
|
|---|
| 595 | security.declareProtected('ZMS Administrator', 'setConfProperty')
|
|---|
| 596 | def setConfProperty(self, key, value):
|
|---|
| 597 | d = self.getConfProperties()
|
|---|
| 598 | if value is None:
|
|---|
| 599 | if d.has_key(key):
|
|---|
| 600 | del d[key]
|
|---|
| 601 | else:
|
|---|
| 602 | d[key] = value
|
|---|
| 603 | self.__attr_conf_dict__ = d
|
|---|
| 604 | self.__attr_conf_dict__ = self.__attr_conf_dict__.copy()
|
|---|
| 605 |
|
|---|
| 606 |
|
|---|
| 607 | """
|
|---|
| 608 | ############################################################################
|
|---|
| 609 | ###
|
|---|
| 610 | ### Configuration-System
|
|---|
| 611 | ###
|
|---|
| 612 | ############################################################################
|
|---|
| 613 | """
|
|---|
| 614 |
|
|---|
| 615 | ############################################################################
|
|---|
| 616 | # ConfManager.manage_customizeSystem:
|
|---|
| 617 | #
|
|---|
| 618 | # Customize system properties.
|
|---|
| 619 | ############################################################################
|
|---|
| 620 | def manage_customizeSystem(self, btn, key, lang, REQUEST, RESPONSE=None):
|
|---|
| 621 | """ ConfManager.manage_customizeSystem """
|
|---|
| 622 |
|
|---|
| 623 | message = ''
|
|---|
| 624 | params = []
|
|---|
| 625 |
|
|---|
| 626 | ##### Import ####
|
|---|
| 627 | if key == 'Import':
|
|---|
| 628 | if btn == 'Import':
|
|---|
| 629 | f = REQUEST['file']
|
|---|
| 630 | createIfNotExists = 1
|
|---|
| 631 | if f:
|
|---|
| 632 | filename = f.filename
|
|---|
| 633 | self.importConfPackage( f, REQUEST, createIfNotExists)
|
|---|
| 634 | else:
|
|---|
| 635 | filename = REQUEST['init']
|
|---|
| 636 | self.importConfPackage( filename, REQUEST, createIfNotExists)
|
|---|
| 637 | message = self.getZMILangStr('MSG_IMPORTED')%('<i>%s</i>'%filename)
|
|---|
| 638 |
|
|---|
| 639 | ##### History ####
|
|---|
| 640 | elif key == 'History':
|
|---|
| 641 | old_active = self.getConfProperty('ZMS.Version.active',0)
|
|---|
| 642 | new_active = REQUEST.get('active',0)
|
|---|
| 643 | old_nodes = self.getConfProperty('ZMS.Version.nodes',['{$}'])
|
|---|
| 644 | new_nodes = self.string_list(REQUEST.get('nodes',''))
|
|---|
| 645 | self.setConfProperty('ZMS.Version.active',new_active)
|
|---|
| 646 | self.setConfProperty('ZMS.Version.nodes',new_nodes)
|
|---|
| 647 | nodes = []
|
|---|
| 648 | if old_active == 1 and new_active == 0:
|
|---|
| 649 | nodes = old_nodes
|
|---|
| 650 | if old_active == 1 and new_active == 1:
|
|---|
| 651 | nodes = self.difference_list( old_nodes, self.getConfProperty('ZMS.Version.nodes',['{$}']))
|
|---|
| 652 | for node in nodes:
|
|---|
| 653 | ob = self.getLinkObj( node)
|
|---|
| 654 | if ob is not None:
|
|---|
| 655 | message += '[%s: %i]'%(node,ob.packHistory())
|
|---|
| 656 | message = self.getZMILangStr('MSG_CHANGED')+message
|
|---|
| 657 |
|
|---|
| 658 | ##### Clients ####
|
|---|
| 659 | elif key == 'Clients':
|
|---|
| 660 | if btn == 'Change':
|
|---|
| 661 | s = REQUEST.get('portal_master','').strip()
|
|---|
| 662 | if s != self.getHome().id:
|
|---|
| 663 | self.setConfProperty('Portal.Master',s)
|
|---|
| 664 | l = []
|
|---|
| 665 | for s in REQUEST.get('portal_clients','').split('\n'):
|
|---|
| 666 | s = s.strip()
|
|---|
| 667 | if s in self.getHome().objectIds(['Folder']):
|
|---|
| 668 | l.append(s)
|
|---|
| 669 | self.setConfProperty('Portal.Clients',l)
|
|---|
| 670 | message = self.getZMILangStr('MSG_CHANGED')
|
|---|
| 671 |
|
|---|
| 672 | ##### MediaDb ####
|
|---|
| 673 | elif key == 'MediaDb':
|
|---|
| 674 | if btn == 'Create':
|
|---|
| 675 | location = REQUEST['mediadb_location'].strip()
|
|---|
| 676 | _mediadb.manage_addMediaDb(self,location)
|
|---|
| 677 | message = self.getZMILangStr('MSG_CHANGED')
|
|---|
| 678 | elif btn == 'Pack':
|
|---|
| 679 | message = _mediadb.manage_packMediaDb(self)
|
|---|
| 680 | elif btn == 'Remove':
|
|---|
| 681 | message = _mediadb.manage_delMediaDb(self)
|
|---|
| 682 |
|
|---|
| 683 | ##### SVN ####
|
|---|
| 684 | elif key == 'SVN':
|
|---|
| 685 | k = REQUEST.get( 'conf_key')
|
|---|
| 686 | v = REQUEST.get( 'conf_value', '')
|
|---|
| 687 | self.setConfProperty( k, v)
|
|---|
| 688 | if btn == 'Change':
|
|---|
| 689 | message = self.getZMILangStr('MSG_CHANGED')
|
|---|
| 690 | elif btn == 'Copy to Location':
|
|---|
| 691 | execute = REQUEST.get('execute')
|
|---|
| 692 | if execute:
|
|---|
| 693 | ids = REQUEST.get('ids',[])
|
|---|
| 694 | l = self.svnCopy(self.getHome(),self.getConfProperty(k,v)+'/'+self.getHome().id,ids)
|
|---|
| 695 | message = self.getZMILangStr('MSG_EXPORTED')%str(len(ids))
|
|---|
| 696 | else:
|
|---|
| 697 | return RESPONSE.redirect( self.url_append_params( 'manage_customizeSvnForm', { 'lang': lang, 'conf_key': k, 'conf_value': v, 'action': 'outgoing'}))
|
|---|
| 698 | elif btn == 'Update from Location':
|
|---|
| 699 | execute = REQUEST.get('execute')
|
|---|
| 700 | if execute:
|
|---|
| 701 | ids = REQUEST.get('ids',[])
|
|---|
| 702 | l = self.svnUpdate(self.getHome(),self.getConfProperty(k,v)+'/'+self.getHome().id,ids)
|
|---|
| 703 | message = self.getZMILangStr('MSG_INSERTED')%str(len(ids))
|
|---|
| 704 | else:
|
|---|
| 705 | return RESPONSE.redirect( self.url_append_params( 'manage_customizeSvnForm', { 'lang': lang, 'conf_key': k, 'conf_value': v, 'action': 'incoming'}))
|
|---|
| 706 |
|
|---|
| 707 | ##### Custom ####
|
|---|
| 708 | elif key == 'Custom':
|
|---|
| 709 | k = REQUEST.get( 'conf_key', '')
|
|---|
| 710 | if btn == 'Change':
|
|---|
| 711 | v = REQUEST.get( 'conf_value', '')
|
|---|
| 712 | self.setConfProperty( k, v)
|
|---|
| 713 | if REQUEST.get('portal_clients'):
|
|---|
| 714 | for portalClient in self.getPortalClients():
|
|---|
| 715 | portalClient.setConfProperty( k, v)
|
|---|
| 716 | params.append('conf_key')
|
|---|
| 717 | message = self.getZMILangStr('MSG_CHANGED')
|
|---|
| 718 | elif btn == 'Delete':
|
|---|
| 719 | self.delConfProperty( k)
|
|---|
| 720 | if REQUEST.get('portal_clients'):
|
|---|
| 721 | for portalClient in self.getPortalClients():
|
|---|
| 722 | portalClient.delConfProperty( k)
|
|---|
| 723 | message = self.getZMILangStr('MSG_DELETED')%int(1)
|
|---|
| 724 |
|
|---|
| 725 | ##### InstalledProducts ####
|
|---|
| 726 | elif key == 'InstalledProducts':
|
|---|
| 727 | if btn == 'Change':
|
|---|
| 728 | self.setConfProperty('InstalledProducts.pil.thumbnail.max',REQUEST.get('pil_thumbnail_max',100))
|
|---|
| 729 | self.setConfProperty('InstalledProducts.pil.hires.thumbnail.max',REQUEST.get('pil_hires_thumbnail_max',600))
|
|---|
| 730 | message = self.getZMILangStr('MSG_CHANGED')
|
|---|
| 731 |
|
|---|
| 732 | ##### Manager ####
|
|---|
| 733 | elif key == 'Manager':
|
|---|
| 734 | if btn == 'Add':
|
|---|
| 735 | meta_type = REQUEST.get('meta_type','')
|
|---|
| 736 | if meta_type == 'Sequence':
|
|---|
| 737 | obj = _sequence.Sequence()
|
|---|
| 738 | self._setObject(obj.id, obj)
|
|---|
| 739 | message = 'Added '+meta_type
|
|---|
| 740 | elif meta_type == 'ZMSLog':
|
|---|
| 741 | obj = zmslog.ZMSLog()
|
|---|
| 742 | self._setObject(obj.id, obj)
|
|---|
| 743 | message = 'Added '+meta_type
|
|---|
| 744 | elif meta_type == 'ZMSWorkflowProvider':
|
|---|
| 745 | obj = ZMSWorkflowProvider.ZMSWorkflowProvider()
|
|---|
| 746 | self._setObject(obj.id, obj)
|
|---|
| 747 | message = 'Added '+meta_type
|
|---|
| 748 | elif meta_type == 'ZMSWorkflowProviderAcquired':
|
|---|
| 749 | obj = ZMSWorkflowProviderAcquired.ZMSWorkflowProviderAcquired()
|
|---|
| 750 | self._setObject(obj.id, obj)
|
|---|
| 751 | message = 'Added '+meta_type
|
|---|
| 752 | elif btn == 'Remove':
|
|---|
| 753 | ids = REQUEST.get('ids',[])
|
|---|
| 754 | if ids:
|
|---|
| 755 | message = 'Removed '+', '.join(ids)
|
|---|
| 756 | self.manage_delObjects(ids=ids)
|
|---|
| 757 |
|
|---|
| 758 | # Return with message.
|
|---|
| 759 | if RESPONSE:
|
|---|
| 760 | d = {'lang': lang,'manage_tabs_message': message}
|
|---|
| 761 | for param in params:
|
|---|
| 762 | d[param] = REQUEST.get( param, '')
|
|---|
| 763 | return RESPONSE.redirect( self.url_append_params( 'manage_customize', d) + '#_%s'%key)
|
|---|
| 764 |
|
|---|
| 765 | return message
|
|---|
| 766 |
|
|---|
| 767 |
|
|---|
| 768 | """
|
|---|
| 769 | ############################################################################
|
|---|
| 770 | ###
|
|---|
| 771 | ### Configuration-Design
|
|---|
| 772 | ###
|
|---|
| 773 | ############################################################################
|
|---|
| 774 | """
|
|---|
| 775 |
|
|---|
| 776 | ############################################################################
|
|---|
| 777 | # ConfManager.manage_customizeDesign:
|
|---|
| 778 | #
|
|---|
| 779 | # Customize design properties.
|
|---|
| 780 | ############################################################################
|
|---|
| 781 | def manage_customizeDesign(self, btn, lang, REQUEST, RESPONSE):
|
|---|
| 782 | """ ConfManager.manage_customizeDesign """
|
|---|
| 783 | message = ''
|
|---|
| 784 | cssId = REQUEST.get('cssId','')
|
|---|
| 785 |
|
|---|
| 786 | # Ex-/Import.
|
|---|
| 787 | # -----------
|
|---|
| 788 | if btn in [ self.getZMILangStr('BTN_EXPORT'), self.getZMILangStr('BTN_IMPORT')]:
|
|---|
| 789 | #-- Theme.
|
|---|
| 790 | home = self.getHome()
|
|---|
| 791 | home_id = home.id
|
|---|
| 792 | temp_folder = self.temp_folder
|
|---|
| 793 | # Init exclude-ids.
|
|---|
| 794 | excl_ids = []
|
|---|
| 795 | # Add clients-folders to exclude-ids.
|
|---|
| 796 | for folder in home.objectValues( ['Folder']):
|
|---|
| 797 | if len( folder.objectValues( ['ZMS'])) > 0:
|
|---|
| 798 | excl_ids.append( absattr( folder.id))
|
|---|
| 799 | # Add content-object artefacts to exclude-ids.
|
|---|
| 800 | for metaObjId in self.getMetaobjIds():
|
|---|
| 801 | for metaObjAttrId in self.getMetaobjAttrIds( metaObjId):
|
|---|
| 802 | metaObjAttr = self.getMetaobjAttr(metaObjId,metaObjAttrId)
|
|---|
| 803 | if metaObjAttr['type'] in self.metaobj_manager.valid_zopetypes:
|
|---|
| 804 | excl_ids.append( metaObjAttrId)
|
|---|
| 805 | # Filter ids.
|
|---|
| 806 | ids = filter( lambda x: x not in excl_ids, home.objectIds(self.metaobj_manager.valid_zopetypes))
|
|---|
| 807 | if btn == self.getZMILangStr('BTN_EXPORT'):
|
|---|
| 808 | if home_id in temp_folder.objectIds():
|
|---|
| 809 | temp_folder.manage_delObjects(ids=[home_id])
|
|---|
| 810 | temp_folder.manage_addFolder(id=home_id,title=home.title_or_id())
|
|---|
| 811 | folder = getattr(temp_folder,home_id)
|
|---|
| 812 | home.manage_copyObjects(ids,REQUEST)
|
|---|
| 813 | folder.manage_pasteObjects(cb_copy_data=None,REQUEST=REQUEST)
|
|---|
| 814 | return RESPONSE.redirect( self.url_append_params('%s/manage_exportObject'%temp_folder.absolute_url(),{'id':home_id,'download:int':1}))
|
|---|
| 815 | if btn == self.getZMILangStr('BTN_IMPORT'):
|
|---|
| 816 | v = REQUEST['theme']
|
|---|
| 817 | temp_filename = _fileutil.extractFilename( v.filename)
|
|---|
| 818 | temp_id = temp_filename[:temp_filename.rfind('.')]
|
|---|
| 819 | filepath = INSTANCE_HOME+'/import/'+temp_filename
|
|---|
| 820 | _fileutil.exportObj( v, filepath)
|
|---|
| 821 | if temp_id in temp_folder.objectIds():
|
|---|
| 822 | temp_folder.manage_delObjects(ids=[temp_id])
|
|---|
| 823 | temp_folder.manage_importObject( temp_filename)
|
|---|
| 824 | folder = getattr( temp_folder, temp_id)
|
|---|
| 825 | home.manage_delObjects(ids=ids)
|
|---|
| 826 | folder.manage_copyObjects(folder.objectIds(),REQUEST)
|
|---|
| 827 | home.manage_pasteObjects(cb_copy_data=None,REQUEST=REQUEST)
|
|---|
| 828 | _fileutil.remove( filepath)
|
|---|
| 829 | temp_folder.manage_delObjects(ids=[temp_id])
|
|---|
| 830 |
|
|---|
| 831 | # Save.
|
|---|
| 832 | # -----
|
|---|
| 833 | if btn == self.getZMILangStr('BTN_SAVE'):
|
|---|
| 834 | #-- Stylesheet.
|
|---|
| 835 | if REQUEST.has_key('cssId'):
|
|---|
| 836 | if REQUEST.get('default'):
|
|---|
| 837 | self.setConfProperty('ZMS.stylesheet',REQUEST.get('cssId'))
|
|---|
| 838 | css = self.getStylesheet( REQUEST.get('cssId'))
|
|---|
| 839 | data = REQUEST.get('stylesheet')
|
|---|
| 840 | title = css.title
|
|---|
| 841 | css.manage_edit(data,title)
|
|---|
| 842 | message = self.getZMILangStr('MSG_CHANGED')
|
|---|
| 843 | #-- Sitemap.
|
|---|
| 844 | if REQUEST.has_key('attr_layoutsitemap'):
|
|---|
| 845 | if len(REQUEST['attr_layoutsitemap'])>0:
|
|---|
| 846 | self.attr_layoutsitemap = int(REQUEST['attr_layoutsitemap'])
|
|---|
| 847 | elif hasattr(self,'attr_layoutsitemap'):
|
|---|
| 848 | delattr(self,'attr_layoutsitemap')
|
|---|
| 849 | message = self.getZMILangStr('MSG_CHANGED')
|
|---|
| 850 |
|
|---|
| 851 | # Upload.
|
|---|
| 852 | # -------
|
|---|
| 853 | elif btn == self.getZMILangStr('BTN_UPLOAD'):
|
|---|
| 854 | #-- ZMI Logo.
|
|---|
| 855 | self.zmi_logo = Image(id='logo', title='', file='')
|
|---|
| 856 | self.zmi_logo.manage_upload(REQUEST['file'],REQUEST)
|
|---|
| 857 | message = self.getZMILangStr('MSG_CHANGED')
|
|---|
| 858 |
|
|---|
| 859 | # Return with message.
|
|---|
| 860 | message = urllib.quote(message)
|
|---|
| 861 | return RESPONSE.redirect('manage_customizeDesignForm?lang=%s&manage_tabs_message=%s&cssId=%s'%(lang,message,cssId))
|
|---|
| 862 |
|
|---|
| 863 |
|
|---|
| 864 | ############################################################################
|
|---|
| 865 | ###
|
|---|
| 866 | ### Interface IZMSWorkflowProvider: delegate to workflow_manager
|
|---|
| 867 | ###
|
|---|
| 868 | ############################################################################
|
|---|
| 869 |
|
|---|
| 870 | def getWfActivities(self):
|
|---|
| 871 | workflow_manager = getattr(self,'workflow_manager',None)
|
|---|
| 872 | if workflow_manager is None:
|
|---|
| 873 | return []
|
|---|
| 874 | return workflow_manager.getActivities()
|
|---|
| 875 |
|
|---|
| 876 | def getWfActivitiesIds(self):
|
|---|
| 877 | workflow_manager = getattr(self,'workflow_manager',None)
|
|---|
| 878 | if workflow_manager is None:
|
|---|
| 879 | return []
|
|---|
| 880 | return workflow_manager.getActivityIds()
|
|---|
| 881 |
|
|---|
| 882 | def getWfActivity(self, id):
|
|---|
| 883 | workflow_manager = getattr(self,'workflow_manager',None)
|
|---|
| 884 | if workflow_manager is None:
|
|---|
| 885 | return None
|
|---|
| 886 | return workflow_manager.getActivity(id)
|
|---|
| 887 |
|
|---|
| 888 | def getWfTransitions(self):
|
|---|
| 889 | workflow_manager = getattr(self,'workflow_manager',None)
|
|---|
| 890 | if workflow_manager is None:
|
|---|
| 891 | return []
|
|---|
| 892 | return workflow_manager.getTransitions()
|
|---|
| 893 |
|
|---|
| 894 |
|
|---|
| 895 | ############################################################################
|
|---|
| 896 | ###
|
|---|
| 897 | ### Interface IZMSMetamodelProvider: delegate
|
|---|
| 898 | ###
|
|---|
| 899 | ############################################################################
|
|---|
| 900 |
|
|---|
| 901 | def getMetaobjManager(self):
|
|---|
| 902 | return self.metaobj_manager
|
|---|
| 903 |
|
|---|
| 904 | def getMetaobjId(self, name):
|
|---|
| 905 | return self.getMetaobjManager().getMetaobjId( name)
|
|---|
| 906 |
|
|---|
| 907 | def getMetaobjIds(self, sort=1, excl_ids=[]):
|
|---|
| 908 | return self.getMetaobjManager().getMetaobjIds( sort, excl_ids)
|
|---|
| 909 |
|
|---|
| 910 | def getMetaobj(self, id):
|
|---|
| 911 | return self.getMetaobjManager().getMetaobj( id)
|
|---|
| 912 |
|
|---|
| 913 | def getMetaobjAttrIds(self, meta_id, types=[]):
|
|---|
| 914 | return self.getMetaobjManager().getMetaobjAttrIds( meta_id, types)
|
|---|
| 915 |
|
|---|
| 916 | def getMetaobjAttrs(self, meta_id, types=[]):
|
|---|
| 917 | return self.getMetaobjManager().getMetaobjAttrs( meta_id)
|
|---|
| 918 |
|
|---|
| 919 | def getMetaobjAttr(self, meta_id, key):
|
|---|
| 920 | return self.getMetaobjManager().getMetaobjAttr( meta_id, key)
|
|---|
| 921 |
|
|---|
| 922 | def getMetaobjAttrIdentifierId(self, meta_id):
|
|---|
| 923 | return self.getMetaobjManager().getMetaobjAttrIdentifierId( meta_id)
|
|---|
| 924 |
|
|---|
| 925 | def notifyMetaobjAttrAboutValue(self, meta_id, key, value):
|
|---|
| 926 | return self.getMetaobjManager().notifyMetaobjAttrAboutValue( meta_id, key, value)
|
|---|
| 927 |
|
|---|
| 928 |
|
|---|
| 929 | ############################################################################
|
|---|
| 930 | ###
|
|---|
| 931 | ### Interface IZMSFormatProvider: delegate
|
|---|
| 932 | ###
|
|---|
| 933 | ############################################################################
|
|---|
| 934 |
|
|---|
| 935 | def getFormatManager(self):
|
|---|
| 936 | return self.format_manager
|
|---|
| 937 |
|
|---|
| 938 | def getTextFormatDefault(self):
|
|---|
| 939 | return self.getFormatManager().getTextFormatDefault()
|
|---|
| 940 |
|
|---|
| 941 | def getTextFormat(self, id, REQUEST):
|
|---|
| 942 | return self.getFormatManager().getTextFormat(id, REQUEST)
|
|---|
| 943 |
|
|---|
| 944 | def getTextFormats(self, REQUEST):
|
|---|
| 945 | return self.getFormatManager().getTextFormats(REQUEST)
|
|---|
| 946 |
|
|---|
| 947 | def getCharFormats(self):
|
|---|
| 948 | return self.getFormatManager().getCharFormats()
|
|---|
| 949 |
|
|---|
| 950 |
|
|---|
| 951 | ############################################################################
|
|---|
| 952 | ###
|
|---|
| 953 | ### Interface IZMSLocale: delegate
|
|---|
| 954 | ###
|
|---|
| 955 | ############################################################################
|
|---|
| 956 |
|
|---|
| 957 | def getLocale(self):
|
|---|
| 958 | return self
|
|---|
| 959 |
|
|---|
| 960 | """
|
|---|
| 961 | def get_manage_langs(self):
|
|---|
| 962 | return self.getLocale().get_manage_langs()
|
|---|
| 963 |
|
|---|
| 964 | def get_manage_lang(self):
|
|---|
| 965 | return self.getLocale().get_manage_lang()
|
|---|
| 966 |
|
|---|
| 967 | def getZMILangStr(self, key, REQUEST=None, RESPONSE=None):
|
|---|
| 968 | return self.getLocale().getZMILangStr( key)
|
|---|
| 969 |
|
|---|
| 970 | def getLangStr(self, key, lang=None):
|
|---|
| 971 | return self.getLocale().getLangStr( key, lang)
|
|---|
| 972 |
|
|---|
| 973 | def getPrimaryLanguage(self):
|
|---|
| 974 | return self.getLocale().getPrimaryLanguage()
|
|---|
| 975 | """
|
|---|
| 976 |
|
|---|
| 977 |
|
|---|
| 978 | # call this to initialize framework classes, which
|
|---|
| 979 | # does the right thing with the security assertions.
|
|---|
| 980 | Globals.InitializeClass(ConfManager)
|
|---|
| 981 |
|
|---|
| 982 | ################################################################################ |
|---|