Beispiel #1
0
def importTheme(folder, theme):
  
  filename = _fileutil.extractFilename(theme)
  id = filename[:filename.rfind('.')]
  
  if filename.endswith('.zexp'):
    ### Store copy of ZEXP in INSTANCE_HOME/import-folder.
    filepath = standard.getINSTANCE_HOME() + '/import/' + filename
    if theme.startswith('http://'):
      initutil = standard.initutil()
      initutil.setConfProperty('HTTP.proxy',REQUEST.get('http_proxy',''))
      zexp = standard.http_import( initutil, theme)
      _fileutil.exportObj( zexp, filepath)
    else:
      packagepath = package_home(globals()) + '/import/' + filename
      try:
        os.stat(_fileutil.getOSPath(filepath))
      except OSError:
        shutil.copy( packagepath, filepath)
    
    ### Import theme from ZEXP.
    _fileutil.importZexp( folder, filename)
  
  else:
    id = filename[:filename.find('-')]
    _confmanager.initConf(folder.content, id, remote=False)
  
  return id
Beispiel #2
0
def initZMS(self, id, titlealt, title, lang, manage_lang, REQUEST):

  ### Constructor.
  obj = ZMS()
  obj.id = id
  self._setObject(obj.id, obj)
  obj = getattr(self, obj.id)

  ### Trashcan.
  trashcan = ZMSTrashcan()
  obj._setObject(trashcan.id, trashcan)

  ### Manager.
  manager = ZMSMetamodelProvider.ZMSMetamodelProvider()
  obj._setObject( manager.id, manager)
  manager = ZMSMetacmdProvider.ZMSMetacmdProvider()
  obj._setObject( manager.id, manager)
  manager = ZMSFormatProvider.ZMSFormatProvider()
  obj._setObject( manager.id, manager)

  ### Init languages.
  obj.setLanguage(lang, REQUEST['lang_label'], '', manage_lang)

  ### Log.
  if REQUEST.get('zmslog'):
    zmslog = ZMSLog( copy_to_stdout=True, logged_entries=[ 'ERROR', 'INFO'])
    obj._setObject(zmslog.id, zmslog)

  ### Init Configuration.
  obj.setConfProperty('HTTP.proxy', REQUEST.get('http_proxy', ''))
  obj.setConfProperty('ZMS.autocommit', 1)

  ### Init ZMS object-model.
  _confmanager.initConf(obj, 'com.zms.foundation', remote=False)
  _confmanager.initConf(obj, 'com.zms.foundation.bootstrap', remote=False)
  _confmanager.initConf(obj, 'com.zms.foundation.theme', remote=False)
  _confmanager.initConf(obj, 'com.zms.index', remote=False)

  ### Init default-configuration.
  _confmanager.initConf(obj, 'default', remote=False)

  ### Init Role-Definitions and Permission Settings.
  obj.initRoleDefs()

  ### Init Properties: active, titlealt, title.
  obj.setObjStateNew(REQUEST)
  obj.setObjProperty('active', 1, lang)
  obj.setObjProperty('titlealt', titlealt, lang)
  obj.setObjProperty('title', title, lang)
  obj.onChangeObj(REQUEST, forced=1)
  
  # Init Object-Children
  obj.initObjChildren(REQUEST)
  
  ### Return new ZMS instance.
  return obj