def manage_undoObjs(self, lang, ids, REQUEST, RESPONSE=None): """ Undo a subordinate object: The objects specified in 'ids' get undone (changes are rolled-back). @param lang: the language-id. @type lang: C{str} @param ids: the list of object-ids. @type ids: C{list} @param REQUEST: the triggering request @type REQUEST: C{ZPublisher.HTTPRequest} @param RESPONSE: the triggering request @type RESPONSE: C{ZPublisher.HTTPResponse} """ message = '' t0 = time.time() ##### Delete objects #### c = 0 for child in self.getChildNodes(): if child.id in ids: if child.inObjStates( ['STATE_NEW', 'STATE_MODIFIED', 'STATE_DELETED'], REQUEST): child.rollbackObjChanges(self, REQUEST) c += 1 # Return with message. if RESPONSE is not None: message += self.getZMILangStr('MSG_UNDONE') % c message += ' (in ' + str(int( (time.time() - t0) * 100.0) / 100.0) + ' secs.)' target = REQUEST.get('manage_target', 'manage_main') return RESPONSE.redirect( '%s?preview=preview&lang=%s&manage_tabs_message=%s' % (target, lang, standard.url_quote(message)))
def manage_import(self, file, lang, REQUEST, RESPONSE=None): """ ZMSCustom.manage_import """ ob = self message = '' if self.meta_id == 'ZMSSysFolder': _ziputil.importZip2Zodb(self, file) message = self.getZMILangStr('MSG_IMPORTED') % ( '<em>%s</em>' % _fileutil.extractFilename(file.filename)) elif self.getType() == 'ZMSRecordSet': message = parseXmlString(self, file) else: ob = _importable.importFile(self, file, REQUEST, _importable.importContent) message = self.getZMILangStr('MSG_IMPORTED') % ( '<em>%s</em>' % ob.display_type(REQUEST)) # Return with message. if RESPONSE is not None: message = standard.url_quote(message) return RESPONSE.redirect( 'manage_main?lang=%s&manage_tabs_message=%s' % (lang, message)) else: return ob
def manage_addZMSModule(self, lang, _sort_id, custom, REQUEST, RESPONSE): """ Add module-node. internal use only @param lang: the language-id. @type lang: C{str} @param id_prefix: the id-prefix. @type id_prefix: C{str} @param REQUEST: the triggering request @type REQUEST: C{ZPublisher.HTTPRequest} @param RESPONSE: the triggering request @type RESPONSE: C{ZPublisher.HTTPResponse} """ meta_id = self.getMetaobjId(custom) metaObj = self.getMetaobj(meta_id) key = self.getMetaobjAttrIds(meta_id)[0] attr = self.getMetaobjAttr(meta_id, key) zexp = attr['custom'] id_prefix = standard.id_prefix(REQUEST.get('id_prefix', 'e')) new_id = self.getNewId(id_prefix) _fileutil.import_zexp(self, zexp, new_id, id_prefix, _sort_id) # Return with message. message = self.getZMILangStr('MSG_INSERTED') % custom RESPONSE.redirect( '%s/%s/manage_main?lang=%s&manage_tabs_message=%s' % (self.absolute_url(), new_id, lang, standard.url_quote(message)))
def manage_eraseObjs(self, lang, ids, REQUEST, RESPONSE=None): """ Delete a subordinate object physically: The objects specified in 'ids' get deleted. @param lang: the language-id. @type lang: C{str} @param ids: the list of object-ids. @type ids: C{list} @param REQUEST: the triggering request @type REQUEST: C{ZPublisher.HTTPRequest} @param RESPONSE: the triggering request @type RESPONSE: C{ZPublisher.HTTPResponse} """ message = '' t0 = time.time() ##### Delete objects #### count = len(ids) self.manage_delObjects(ids=ids) # Return with message. if RESPONSE is not None: message += self.getZMILangStr('MSG_DELETED') % count message += ' (in ' + str(int( (time.time() - t0) * 100.0) / 100.0) + ' secs.)' target = REQUEST.get('manage_target', 'manage_main') return RESPONSE.redirect( '%s?lang=%s&manage_tabs_message=%s' % (target, lang, standard.url_quote(message)))
def manage_changeLanguages(self, lang, btn, REQUEST, RESPONSE): """ MultiLanguageManager.manage_changeLanguages """ # Delete. # ------- if btn == 'BTN_DELETE': ids = REQUEST.get('ids', []) for id in ids: self.delLanguage(id) # Change. # ------- elif btn == 'BTN_SAVE': for id in self.getLangIds(): newLabel = REQUEST.get('%s_label' % id).strip() newParent = REQUEST.get('%s_parent' % id).strip() newManage = REQUEST.get('%s_manage' % id).strip() self.setLanguage(id, newLabel, newParent, newManage) # Insert newId = REQUEST.get('language_id').strip() if len(newId) > 0: newLabel = REQUEST.get('language_label').strip() if len(self.getLangIds()) == 0: newParent = '' else: newParent = REQUEST.get('language_parent').strip() newManage = REQUEST.get('language_manage').strip() self.setLanguage(newId, newLabel, newParent, newManage) # Return with message. message = standard.url_quote(self.getZMILangStr('MSG_CHANGED')) return RESPONSE.redirect( 'manage_customizeLanguagesForm?lang=%s&manage_tabs_message=%s' % (lang, message))
def manage_copyObjects(self, ids=None, REQUEST=None, RESPONSE=None): """Put a reference to the objects named in ids in the clip board""" standard.writeLog(self, "[CopySupport.manage_copyObjects]") super(self.__class__, self).manage_copyObjects(ids, REQUEST, RESPONSE) # Return with message. if RESPONSE is not None: message = '' RESPONSE.redirect('manage_main?lang=%s&manage_tabs_message=%s' % (REQUEST['lang'], standard.url_quote(message)))
def manage_changeProcess(self, lang, btn='', key='', REQUEST=None, RESPONSE=None): """ FilterManager.manage_changeProcess """ message = '' id = REQUEST.get('id', '') # Change. # ------- if btn == 'BTN_SAVE': newId = REQUEST.get('inpId').strip() newAcquired = 0 newName = REQUEST.get('inpName').strip() newType = REQUEST.get('inpType').strip() newCommand = REQUEST.get('inpCommand').strip() id = self.setProcess(id, newId, newAcquired, newName, newType, newCommand) message = self.getZMILangStr('MSG_CHANGED') # Delete. # ------- elif btn == 'BTN_DELETE': ids = REQUEST.get('ids', []) for id in ids: self.delProcess(id) message = self.getZMILangStr('MSG_DELETED')%len(ids) # Export. # ------- elif btn == 'BTN_EXPORT': return self.exportXml(REQUEST, RESPONSE) # Import. # ------- elif btn == 'BTN_IMPORT': f = REQUEST['file'] if f: filename = f.filename self.importXml(xml=f) else: filename = REQUEST['init'] self.importConf(filename) message = self.getZMILangStr('MSG_IMPORTED')%('<em>%s</em>'%filename) # Insert. # ------- elif btn == 'BTN_INSERT': newId = REQUEST.get('newId').strip() newAcquired = 0 newName = REQUEST.get('newName').strip() newType = REQUEST.get('newType').strip() id = self.setProcess(None, newId, newAcquired, newName, newType) message = self.getZMILangStr('MSG_INSERTED')%id # Return with message. message = standard.url_quote(message) return RESPONSE.redirect('manage_main?id=%s&lang=%s&manage_tabs_message=%s'%(id, lang, message))
def manage_initObjChild(self, id, type, lang, REQUEST, RESPONSE=None): """ ObjChildren.manage_initObjChild """ # Create. obj = self.initObjChild(id, self.getNewSortId(), type, REQUEST) # Return with message. if RESPONSE is not None: message = self.getZMILangStr('MSG_INSERTED') % obj.display_type( REQUEST) message = standard.url_quote(message) target = REQUEST.get('manage_target', '%s/manage_main' % obj.id) RESPONSE.redirect('%s?lang=%s&manage_tabs_message=%s' % (target, lang, message))
def manage_changeProperties(self, submit, REQUEST, RESPONSE): """ MediaDb.manage_changeProperties """ message = '' # Change. if submit == 'Change': location = REQUEST.get('location', self.location) self.setLocation(location) # Return. if RESPONSE is not None: RESPONSE.redirect('manage_properties?manage_tabs_message=%s' % standard.url_quote(message))
def manage_changeProperties(self, btn, lang, REQUEST, RESPONSE): """ ZMSZCatalogAdapter.manage_changeProperties """ message = '' ids = REQUEST.get('objectIds', []) # Delegate to connectors. # ----------------------- for connector in self.getConnectors(): if self.getConfProperty('zms.search.adapter.id', self.id) == self.id: self.setConfProperty('zms.search.connector.id', connector.id) message += connector.manage_changeProperties( connector.id in ids, btn, lang, REQUEST) # Add. # ---- if btn == 'Add': meta_type = REQUEST['meta_type'] connector = self.addConnector(meta_type) message += 'Added ' + meta_type # Save. # ----- elif btn == 'Save': self.setConfProperty('ZMS.CatalogAwareness.active', REQUEST.get('catalog_awareness_active') == 1) self._ids = REQUEST.get('ids', []) attrs = {} for attr_id in REQUEST.get('attr_ids', []): attrs[attr_id] = { 'boost': float(REQUEST.get('boost_%s' % attr_id, '1.0')), 'type': REQUEST.get('type_%s' % attr_id, 'text') } self.setAttrs(attrs) message += self.getZMILangStr('MSG_CHANGED') # Remove. # ------- elif btn == 'Remove': if len(ids) > 0: self.manage_delObjects(ids) message += self.getZMILangStr('MSG_DELETED') % len(ids) # Return with message. message = standard.url_quote(message) return RESPONSE.redirect( 'manage_main?lang=%s&manage_tabs_message=%s#%s' % (lang, message, REQUEST.get('tab')))
def manage_changeProperties(self, REQUEST, RESPONSE): """ ZMSAttributeContainer.manage_changeProperties """ message = '' for key in self.getObjAttrs(): obj_attr = self.getObjAttr(key) if obj_attr['multilang']: for lang in self.getLangIds(): REQUEST.set('lang', lang) self.setReqProperty(key, REQUEST, 1) else: REQUEST.set('lang', self.getPrimaryLanguage()) self.setReqProperty(key, REQUEST, 1) # Return with message. return RESPONSE.redirect( 'manage_propertiesForm?manage_tabs_message=%s' % (standard.url_quote(message)))
def manage_addZMS(self, lang, manage_lang, REQUEST, RESPONSE): """ manage_addZMS """ message = '' t0 = time.time() if REQUEST['btn'] == 'Add': ##### Add Home #### homeElmnt = Folder(REQUEST['folder_id']) self._setObject(homeElmnt.id, homeElmnt) homeElmnt = [x for x in self.objectValues() if x.id == homeElmnt.id][0] ##### Add ZMS #### titlealt = 'ZMS home' title = 'ZMS - Python-based Content Management System for Science, Technology and Medicine' obj = initZMS(homeElmnt, 'content', titlealt, title, lang, manage_lang, REQUEST) ##### Add Theme #### themeId = importTheme(homeElmnt, REQUEST['theme']) obj.setConfProperty('ZMS.theme', themeId) ##### Default content #### if REQUEST.get('initialization', 0) == 1: initContent(obj, 'content.default.zip', REQUEST) ##### Configuration #### #-- Search initContent(obj, 'com.zms.search.content.xml', REQUEST) # Initialize catalogs. obj.getCatalogAdapter().reindex_all() # Initialize access. obj.synchronizePublicAccess() # Return with message. message = obj.getLangStr('MSG_INSERTED', manage_lang) % obj.meta_type message += ' (in ' + str(int( (time.time() - t0) * 100.0) / 100.0) + ' secs.)' RESPONSE.redirect( '%s/%s/manage?manage_tabs_message=%s' % (homeElmnt.absolute_url(), obj.id, standard.url_quote(message))) else: RESPONSE.redirect('%s/manage_main' % self.absolute_url())
def manage_changeProperties(self, lang, REQUEST=None): """ ZMSTrashcan.manage_changeProperties """ if REQUEST.get('btn') in ['BTN_CANCEL', 'BTN_BACK']: return REQUEST.RESPONSE.redirect('manage_main?lang=%s' % lang) ##### Garbage Collection ##### setattr(self, 'garbage_collection', REQUEST.get('garbage_collection', '')) self.run_garbage_collection(forced=1) # Return with message. message = self.getZMILangStr('MSG_CHANGED') if REQUEST and hasattr(REQUEST, 'RESPONSE'): if REQUEST.RESPONSE: return REQUEST.RESPONSE.redirect( 'manage_properties?lang=%s&manage_tabs_message=%s' % (lang, standard.url_quote(message)))
def manage_changeProperties(self, submit, currentvalue, REQUEST, RESPONSE): """ Sequence.manage_changeProperties """ message = '' # Set current value. if submit == 'Change': if currentvalue >= self.value: self.value = currentvalue # Fetch next value. if submit == 'Next': self.nextVal() # Return. if RESPONSE is not None: RESPONSE.redirect( '%s?manage_tabs_message=%s' % (REQUEST['HTTP_REFERER'], standard.url_quote(message)))
def manage_deleteObjs(self, lang, ids, REQUEST, RESPONSE=None): """ Delete a subordinate object logically: The objects specified in 'ids' get deleted (moved to trashcan). @param lang: the language-id. @type lang: C{str} @param ids: the list of object-ids. @type ids: C{list} @param REQUEST: the triggering request @type REQUEST: C{ZPublisher.HTTPRequest} @param RESPONSE: the triggering request @type RESPONSE: C{ZPublisher.HTTPResponse} """ message = '' t0 = time.time() ##### Delete objects #### versionMgrCntnrs = [] for child in self.getChildNodes(): if child.id in ids: if child.getAutocommit() or child.inObjStates(['STATE_NEW'], REQUEST): self.moveObjsToTrashcan([child.id], REQUEST) else: child.setObjStateDeleted(REQUEST) versionCntnr = child.getVersionContainer() if versionCntnr not in versionMgrCntnrs: versionMgrCntnrs.append(versionCntnr) ##### VersionManager #### for versionCntnr in versionMgrCntnrs: versionCntnr.onChangeObj(REQUEST) # Return with message. if RESPONSE is not None: message += self.getZMILangStr('MSG_TRASHED') % len(ids) message += ' (in ' + str(int( (time.time() - t0) * 100.0) / 100.0) + ' secs.)' target = REQUEST.get('manage_target', 'manage_main') return RESPONSE.redirect( '%s?preview=preview&lang=%s&manage_tabs_message=%s' % (target, lang, standard.url_quote(message)))
def manage_pasteObjs(self, REQUEST, RESPONSE=None): """ CopySupport.manage_pasteObjs """ id_prefix = REQUEST.get('id_prefix', 'e') standard.writeBlock(self, "[CopySupport.manage_pasteObjs]") t0 = time.time() # Analyze request cb_copy_data = self._get_cb_copy_data(cb_copy_data=None, REQUEST=REQUEST) op = cb_copy_data[0] cp = (op, cb_copy_data[1]) cp = _cb_encode(cp) ids = [self._get_id(x.getId()) for x in self._get_obs(cp)] oblist = self._get_obs(cp) # Paste objects. action = ['Copy', 'Move'][op == OP_MOVE] standard.triggerEvent(self, 'before%sObjsEvt' % action) self.manage_pasteObjects(cb_copy_data=None, REQUEST=REQUEST) standard.triggerEvent(self, 'after%sObjsEvt' % action) # Sort order (I). self._set_sort_ids(ids=ids, op=op, REQUEST=REQUEST) # Move objects. if op == OP_MOVE: normalize_ids_after_move(self, id_prefix=id_prefix, ids=ids) # Copy objects. else: normalize_ids_after_copy(self, id_prefix=id_prefix, ids=ids) # Sort order (II). self.normalizeSortIds() # Return with message. if RESPONSE is not None: message = standard.pybytes(self.getZMILangStr('MSG_PASTED')) message += ' (in ' + str(int( (time.time() - t0) * 100.0) / 100.0) + ' secs.)' RESPONSE.redirect('manage_main?lang=%s&manage_tabs_message=%s' % (REQUEST['lang'], standard.url_quote(message)))
def manage_changeWorkflow(self, lang, key='', btn='', REQUEST=None, RESPONSE=None): """ ZMSWorkflowProvider.manage_changeWorkflow """ message = '' # Active. # ------- if key == 'custom' and btn == 'BTN_SAVE': # Autocommit & Nodes. old_autocommit = getattr(self, 'autocommit', 1) new_autocommit = REQUEST.get('workflow', 0) == 0 self.autocommit = new_autocommit self.nodes = standard.string_list(REQUEST.get('nodes', '')) if old_autocommit == 0 and new_autocommit == 1: self.doAutocommit(lang, REQUEST) message = self.getZMILangStr('MSG_CHANGED') # Return with message. message = standard.url_quote(message) return RESPONSE.redirect('manage_main?lang=%s&manage_tabs_message=%s#_%s'%(lang, message, key)) ################################################################################
def manage_addZMSCustomDefault(self, lang, id_prefix, _sort_id, REQUEST, RESPONSE): """ Add default node. internal use only @param lang: the language-id. @type lang: C{str} @param id_prefix: the id-prefix. @type id_prefix: C{str} @param REQUEST: the triggering request @type REQUEST: C{ZPublisher.HTTPRequest} @param RESPONSE: the triggering request @type RESPONSE: C{ZPublisher.HTTPResponse} """ attr = self.getMetaobjAttr(self.meta_id, id_prefix) zexp = attr['custom'] new_id = self.getNewId(id_prefix) _fileutil.import_zexp(self, zexp, new_id, id_prefix, _sort_id) # Return with message. message = self.getZMILangStr('MSG_INSERTED') % attr['name'] RESPONSE.redirect( '%s/%s/manage_main?lang=%s&manage_tabs_message=%s' % (self.absolute_url(), new_id, lang, standard.url_quote(message)))
def manage_changeFilter(self, lang, btn='', key='', REQUEST=None, RESPONSE=None): """ FilterManager.manage_changeFilter """ message = '' id = REQUEST.get('id', '') index = REQUEST.get('index', -1) # Change. # ------- if btn == 'BTN_SAVE': cp = self.getFilter(id) # Filter. newId = REQUEST.get('inpId').strip() newAcquired = 0 newName = REQUEST.get('inpName').strip() newFormat = REQUEST.get('inpFormat').strip() newContentType = REQUEST.get('inpContentType').strip() newDescription = REQUEST.get('inpDescription').strip() newRoles = REQUEST.get('inpRoles', []) newMetaTypes = REQUEST.get('inpMetaTypes', []) id = self.setFilter(id, newId, newAcquired, newName, newFormat, newContentType, newDescription, newRoles, newMetaTypes) # Filter Processes. index = 0 for filterProcess in cp.get('processes', []): newProcessId = REQUEST.get('newFilterProcessId_%i'%index, '').strip() newProcessFile = REQUEST.get('newFilterProcessFile_%i'%index) if isinstance(newProcessFile, ZPublisher.HTTPRequest.FileUpload): if len(getattr(newProcessFile, 'filename', ''))==0: newProcessFile = filterProcess.get('file', None) else: newProcessFile = _blobfields.createBlobField(self, _blobfields.MyFile, newProcessFile) self.setFilterProcess(id, index, newProcessId, newProcessFile) index += 1 # New Filter Process? newProcessId = REQUEST.get('newFilterProcessId_%i'%index, '').strip() newProcessFile = REQUEST.get('newFilterProcessFile_%i'%index) if newProcessId: self.setFilterProcess(id, newProcessId, newProcessFile) # Return with message. message = self.getZMILangStr('MSG_CHANGED') # Delete. # ------- elif btn == 'BTN_DELETE': if key == 'obj': ids = REQUEST.get('ids', []) for id in ids: self.delFilter(id) message = self.getZMILangStr('MSG_DELETED')%len(ids) elif key == 'attr': ids = [REQUEST.get('id')] for id in ids: if id is not None: self.delFilterProcess(id, index) message = self.getZMILangStr('MSG_DELETED')%len(ids) # Export. # ------- elif btn == 'BTN_EXPORT': return self.exportXml(REQUEST, RESPONSE) # Import. # ------- elif btn == 'BTN_IMPORT': f = REQUEST['file'] if f: filename = f.filename self.importXml(xml=f) else: filename = REQUEST['init'] self.importConf(filename) message = self.getZMILangStr('MSG_IMPORTED')%('<em>%s</em>'%filename) # Insert. # ------- elif btn == 'BTN_INSERT': newId = REQUEST.get('newId').strip() newAcquired = 0 newName = REQUEST.get('newName').strip() newFormat = REQUEST.get('newFormat').strip() newContentType = REQUEST.get('newContentType').strip() id = self.setFilter(None, newId, newAcquired, newName, newFormat, newContentType) message = self.getZMILangStr('MSG_INSERTED')%id # Move to. # -------- elif btn == 'move_to': pos = REQUEST['pos'] self.moveFilterProcess(id, index, pos) message = self.getZMILangStr('MSG_MOVEDOBJTOPOS')%(("<em>%s</em>"%index), (pos+1)) # Return with message. message = standard.url_quote(message) return RESPONSE.redirect('manage_main?id=%s&index:int=%i&lang=%s&manage_tabs_message=%s'%(id, index, lang, message))
def manage_changeLangDictProperties(self, lang, btn, REQUEST, RESPONSE=None): """ MultiLanguageManager.manage_changeLangDictProperties """ # Delete. # ------- if btn == 'BTN_DELETE': ids = REQUEST.get('ids', []) dict = self.get_lang_dict() lang_dict = {} for id in dict.keys(): if not id in ids: lang_dict[id] = dict[id] self.set_lang_dict(lang_dict) # Change. # ------- elif btn == 'BTN_SAVE': d = self.get_lang_dict() lang_dict = {} for key in d.keys(): for lang_id in self.getLangIds(): lang_dict[key] = lang_dict.get(key, {}) enabled = lang_id not in d[key].get('acquired', []) if enabled: lang_dict[key][lang_id] = REQUEST['%s_value_%s' % (key, lang_id)].strip() # Insert key = REQUEST['_key'].strip() if len(key) > 0: lang_dict = self.get_lang_dict() lang_dict[key] = {} for lang_id in self.getLangIds(): lang_dict[key][lang_id] = REQUEST['_value_%s' % lang_id].strip() self.set_lang_dict(lang_dict) # Export. # ------- elif btn == 'BTN_EXPORT': ids = REQUEST.get('ids', []) return exportXml(self, ids, REQUEST, RESPONSE) # Import. # ------- elif btn == 'BTN_IMPORT': f = REQUEST['file'] if f: filename = f.filename importXml(self, xml=f) else: filename = REQUEST['init'] self.importConf(filename, createIfNotExists=1) message = self.getZMILangStr('MSG_IMPORTED') % ('<i>%s</i>' % filename) # Return with message. message = standard.url_quote(self.getZMILangStr('MSG_CHANGED')) return RESPONSE.redirect( 'manage_customizeLanguagesForm?lang=%s&manage_tabs_message=%s#langdict' % (lang, message))
def manage_changeActivities(self, lang, btn='', REQUEST=None, RESPONSE=None): """ ZMSWorkflowActivitiesManager.manage_changeActivities """ message = '' id = REQUEST.get('id', '') # Cancel. # ------- if btn in ['BTN_CANCEL', 'BTN_BACK']: id = '' # Change. # ------- if btn == 'BTN_SAVE': item = self.getActivity(id, for_export=True) newId = REQUEST.get('inpId').strip() newName = REQUEST.get('inpName').strip() newIconClazz = REQUEST.get('inpIconClazz', '').strip() newIcon = None if len(newIconClazz) == 0: newIcon = REQUEST.get('inpIcon', '') if isinstance(newIcon, ZPublisher.HTTPRequest.FileUpload): if len(getattr(newIcon, 'filename', '')) == 0: newIcon = item.get('icon', None) else: newIcon = _blobfields.createBlobField( self, _blobfields.MyImage, newIcon) id = self.setActivity(item.get('id', None), newId, newName, newIconClazz, newIcon) message = self.getZMILangStr('MSG_CHANGED') # Delete. # ------- elif btn == 'BTN_DELETE': id = self.delItem(id, 'activities') message = self.getZMILangStr('MSG_CHANGED') # Insert. # ------- elif btn == 'BTN_INSERT': item = {} newId = REQUEST.get('newId').strip() newName = REQUEST.get('newName').strip() newIconClazz = REQUEST.get('newIconClazz', '').strip() newIcon = None if len(newIconClazz) == 0: newIcon = REQUEST.get('newIcon', '') if isinstance(newIcon, ZPublisher.HTTPRequest.FileUpload): if len(getattr(newIcon, 'filename', '')) == 0: newIcon = item.get('icon', None) else: newIcon = _blobfields.createBlobField( self, _blobfields.MyImage, newIcon) id = self.setActivity(item.get('id', None), newId, newName, newIconClazz, newIcon) message = self.getZMILangStr('MSG_INSERTED') % id # Move to. # -------- elif btn == 'move_to': pos = REQUEST['pos'] self.moveItem(id, pos, 'activities') message = self.getZMILangStr('MSG_MOVEDOBJTOPOS') % ( ("<i>%s</i>" % id), (pos + 1)) id = '' # Return with message. message = standard.url_quote(message) return RESPONSE.redirect('manage_main?lang=%s&manage_tabs_message=%s' % (lang, message))
def manage_changeTransitions(self, lang, btn='', key='', REQUEST=None, RESPONSE=None): """ ZMSWorkflowTransitionsManager.manage_changeTransitions """ message = '' id = REQUEST.get('id', '') # Cancel. # ------- if btn in ['BTN_CANCEL', 'BTN_BACK']: id = '' # Change. # ------- if btn == 'BTN_SAVE': item = self.getTransition(id) newId = REQUEST.get('inpId').strip() newIconClazz = REQUEST.get('inpIconClazz', '') newName = REQUEST.get('inpName').strip() newType = REQUEST.get('inpType', 'DTML Method').strip() newFrom = REQUEST.get('inpFrom', []) newTo = REQUEST.get('inpTo', []) newPerformer = REQUEST.get('inpPerformer', []) newData = REQUEST.get('inpData', '').strip() message += self.setTransition(item.get('id', None), newId, newName, newType, newIconClazz, newFrom, newTo, newPerformer, newData) message += self.getZMILangStr('MSG_CHANGED') id = newId # Delete. # ------- elif btn == 'BTN_DELETE': id = self.delItem(id, 'transitions') message = self.getZMILangStr('MSG_CHANGED') # Insert. # ------- elif btn == 'BTN_INSERT': item = {} newId = REQUEST.get('newId').strip() newName = REQUEST.get('newName').strip() newIconClazz = REQUEST.get('inpIconClazz', '') newType = REQUEST.get('newType', 'DTML Method').strip() message += self.setTransition(item.get('id', None), newId, newName, newType, newIconClazz) message += self.getZMILangStr('MSG_INSERTED') % id id = newId # Move to. # -------- elif btn == 'move_to': pos = REQUEST['pos'] self.moveItem(id, pos, 'transitions') message = self.getZMILangStr('MSG_MOVEDOBJTOPOS') % ( ("<i>%s</i>" % id), (pos + 1)) id = '' # Return with message. message = standard.url_quote(message) return RESPONSE.redirect( 'manage_main?id=%s&lang=%s&key=%s&manage_tabs_message=%s' % (id, lang, key, message))
def manage_changeTextformat(self, lang, btn, REQUEST, RESPONSE): """ ZMSTextformatManager.manage_changeTextformat """ message = '' id = REQUEST.get('id', '') # Change. # ------- if btn == 'BTN_SAVE': old_id = REQUEST['id'] id = REQUEST['new_id'].strip() display = REQUEST['new_display'].strip() tag = REQUEST['new_tag'].strip() subtag = REQUEST['new_subtag'].strip() attrs = REQUEST['new_attrs'].strip() richedit = REQUEST.get('new_richedit', 0) usage = REQUEST.get('new_usage', []) self.setTextformat(old_id, id, display, self.get_manage_lang(), tag, subtag, attrs, richedit, usage) if 'new_default' in REQUEST: self.setDefaultTextformat(id) id = '' message = self.getZMILangStr('MSG_CHANGED') # Delete. # ------- elif btn == 'BTN_DELETE': if id: ids = [id] else: ids = REQUEST.get('ids', []) for id in ids: self.delTextformat(id) id = '' message = self.getZMILangStr('MSG_DELETED') % len(ids) # Insert. # ------- elif btn == 'BTN_INSERT': id = REQUEST['_id'].strip() display = REQUEST['_display'].strip() self.setTextformat(None, id, display, self.get_manage_lang()) message = self.getZMILangStr('MSG_CHANGED') # Export. # ------- elif btn == 'BTN_EXPORT': value = [] ids = REQUEST.get('ids', []) fmts = self.textformats for i in range(len(fmts) // 2): id = fmts[i * 2] ob = fmts[i * 2 + 1] if id in ids or len(ids) == 0: value.append({'key': id, 'value': ob}) if len(value) == 1: value = value[0] content_type = 'text/xml; charset=utf-8' filename = 'export.textfmt.xml' export = self.getXmlHeader() + self.toXmlString(value, 1) RESPONSE.setHeader('Content-Type', content_type) RESPONSE.setHeader('Content-Disposition', 'attachment;filename="%s"' % filename) return export # Import. # ------- elif btn == 'BTN_IMPORT': f = REQUEST['file'] if f: filename = f.filename self.importTextformatXml(xml=f) else: filename = REQUEST['init'] self.importConf(filename, createIfNotExists=1) message = self.getZMILangStr('MSG_IMPORTED') % ('<i>%s</i>' % filename) # Return with message. if RESPONSE: message = standard.url_quote(message) return RESPONSE.redirect( 'manage_textformats?lang=%s&manage_tabs_message=%s&id=%s' % (lang, message, id)) return message
def manage_changeMetacmds(self, btn, lang, REQUEST, RESPONSE): """ ZMSMetacmdProvider.manage_changeMetacmds """ message = '' id = REQUEST.get('id', '') # Acquire. # -------- if btn == 'BTN_ACQUIRE': aq_ids = REQUEST.get('aq_ids', []) for newId in aq_ids: newAcquired = 1 self.setMetacmd(None, newId, newAcquired) message = self.getZMILangStr('MSG_INSERTED')%str(len(aq_ids)) # Change. # ------- elif btn == 'BTN_SAVE': id = REQUEST['id'] newId = REQUEST['el_id'].strip() newAcquired = 0 newPackage = REQUEST.get('el_package', '').strip() newRevision = REQUEST.get('el_revision', '').strip() newName = REQUEST.get('el_name', '').strip() newTitle = REQUEST.get('el_title', '').strip() newMethod = REQUEST.get('el_method') newData = REQUEST.get('el_data', '').strip() newExecution = REQUEST.get('el_execution', 0) newDescription = REQUEST.get('el_description', '').strip() newIconClazz = REQUEST.get('el_icon_clazz', '') newMetaTypes = REQUEST.get('el_meta_types', []) newRoles = REQUEST.get('el_roles', []) newNodes = REQUEST.get('el_nodes', '') id = self.setMetacmd(id, newId, newAcquired, newPackage, newRevision, newName, \ newTitle, newMethod, newData, newExecution, newDescription, newIconClazz, \ newMetaTypes, newRoles, newNodes) message = self.getZMILangStr('MSG_CHANGED') # Copy. # ----- elif btn == 'BTN_COPY': metaOb = self.getMetaCmd(id) if metaOb.get('acquired', 0) == 1: portalMaster = self.getPortalMaster() if portalMaster is not None: REQUEST.set('ids', [id]) xml = portalMaster.manage_changeMetacmds('BTN_EXPORT', lang, REQUEST, RESPONSE) self.importXml(xml=xml) message = self.getZMILangStr('MSG_IMPORTED')%('<i>%s</i>'%id) # Delete. # ------- elif btn == 'BTN_DELETE': if id: ids = [id] else: ids = REQUEST.get('ids', []) for id in ids: self.delMetacmd(id) id = '' message = self.getZMILangStr('MSG_DELETED')%len(ids) # Export. # ------- elif btn == 'BTN_EXPORT': revision = '0.0.0' value = [] ids = REQUEST.get('ids', []) for id in self.getMetaCmdIds(): if id in ids or len(ids) == 0: metaCmd = self.getMetaCmd(id) revision = metaCmd.get('revision', '0.0.0') el_id = metaCmd['id'] el_name = metaCmd['name'] el_title = metaCmd.get('title', '') el_meta_type = metaCmd['meta_type'] el_description = metaCmd['description'] el_icon_clazz = metaCmd.get('icon_clazz', '') el_meta_types = metaCmd['meta_types'] el_roles = metaCmd['roles'] el_execution = metaCmd['execution'] el_data = zopeutil.readObject(metaCmd['home'], metaCmd['id']) # Value. value.append({'id':el_id,'revision':revision,'name':el_name,'title':el_title,'description':el_description,'meta_types':el_meta_types,'roles':el_roles,'execution':el_execution,'icon_clazz':el_icon_clazz,'meta_type':el_meta_type,'data':el_data}) # XML. if len(ids)==1: filename = '%s-%s.metacmd.xml'%(ids[0], revision) else: filename = 'export.metacmd.xml' content_type = 'text/xml; charset=utf-8' export = self.getXmlHeader() + self.toXmlString(value, 1) RESPONSE.setHeader('Content-Type', content_type) RESPONSE.setHeader('Content-Disposition', 'attachment;filename="%s"'%filename) return export # Import. # ------- elif btn == 'BTN_IMPORT': f = REQUEST['file'] if f: filename = f.filename self.importXml(xml=f) else: filename = REQUEST['init'] self.importConf(filename) message = self.getZMILangStr('MSG_IMPORTED')%('<i>%s</i>'%f.filename) # Insert. # ------- elif btn == 'BTN_INSERT': newId = REQUEST.get('_id').strip() newAcquired = 0 newPackage = REQUEST.get('_package', '').strip() newRevision = REQUEST.get('_revision', '0.0.0').strip() newName = REQUEST.get('_name').strip() newTitle = REQUEST.get('_title').strip() newMethod = REQUEST.get('_type', 'DTML Method') newData = None newExecution = REQUEST.get('_execution', 0) newIconClazz = REQUEST.get('_icon_clazz', '') id = self.setMetacmd(None, newId, newAcquired, newPackage, newRevision, newName, newTitle, newMethod, newData, newExecution, newIconClazz=newIconClazz) message = self.getZMILangStr('MSG_INSERTED')%id # Sync with repository. self.getRepositoryManager().exec_auto_commit(self, id) # Return with message. message = standard.url_quote(message) return RESPONSE.redirect('manage_main?lang=%s&manage_tabs_message=%s&id=%s'%(lang, message, id))
def manage_changeCharformat(self, lang, btn, REQUEST, RESPONSE): """ ZMSCharformatManager.manage_changeCharformat """ message = '' id = REQUEST.get('id', '') # Change. # ------- if btn == 'BTN_SAVE': newId = REQUEST['new_id'].strip() newIconClazz = REQUEST.get('new_icon_clazz', '') newDisplay = REQUEST['new_display'].strip() newTag = REQUEST['new_tag'].strip() newAttrs = REQUEST['new_attrs'].strip() newJS = REQUEST['new_js'].strip() id = self.setCharformat(id, newId, newIconClazz, newDisplay, newTag, newAttrs, newJS) message = self.getZMILangStr('MSG_CHANGED') # Delete. # ------- elif btn == 'BTN_DELETE': if id: ids = [id] else: ids = REQUEST.get('ids', []) for id in ids: self.delCharformat(id) id = '' message = self.getZMILangStr('MSG_DELETED') % len(ids) # Insert. # ------- elif btn == 'BTN_INSERT': fmts = self.getCharFormats() newId = REQUEST['_id'].strip() newIconClazz = REQUEST.get('_icon_clazz', '') newDisplay = REQUEST['_display'].strip() id = self.setCharformat(None, newId, newIconClazz, newDisplay) message = self.getZMILangStr('MSG_INSERTED') % id # Export. # ------- elif btn == 'BTN_EXPORT': ids = REQUEST.get('ids', []) value = [ x.copy() for x in self.getCharFormats() if x['id'] in ids or len(ids) == 0 ] if len(value) == 1: value = value[0] content_type = 'text/xml; charset=utf-8' filename = 'export.charfmt.xml' export = self.getXmlHeader() + self.toXmlString(value, 1) RESPONSE.setHeader('Content-Type', content_type) RESPONSE.setHeader('Content-Disposition', 'attachment;filename="%s"' % filename) return export # Import. # ------- elif btn == 'BTN_IMPORT': f = REQUEST['file'] if f: filename = f.filename self.importCharformatXml(xml=f) else: filename = REQUEST['init'] self.importConf(filename, createIfNotExists=1) message = self.getZMILangStr('MSG_IMPORTED') % ('<i>%s</i>' % filename) # Move to. # -------- elif btn == 'move_to': pos = REQUEST['pos'] id = int(id) self.moveCharformat(self, id, pos) message = self.getZMILangStr('MSG_MOVEDOBJTOPOS') % ( ("<i>%s</i>" % str(id)), (pos + 1)) id = '' # Return with message. message = standard.url_quote(message) return RESPONSE.redirect( 'manage_charformats?lang=%s&manage_tabs_message=%s&id=%s' % (lang, message, id))
def manage_changeWorkflow(self, lang, btn='', key='properties', REQUEST=None, RESPONSE=None): """ ZMSWorkflowProvider.manage_changeWorkflow """ message = '' # Version Control. # ----------- if key == 'history': old_active = self.getConfProperty('ZMS.Version.active', 0) new_active = REQUEST.get('active', 0) old_nodes = self.getConfProperty('ZMS.Version.nodes', ['{$}']) new_nodes = standard.string_list(REQUEST.get('nodes', '')) self.setConfProperty('ZMS.Version.active', new_active) self.setConfProperty('ZMS.Version.nodes', new_nodes) nodes = [] if old_active == 1 and new_active == 0: nodes = old_nodes if old_active == 1 and new_active == 1: nodes = standard.difference_list( old_nodes, self.getConfProperty('ZMS.Version.nodes', ['{$}'])) for node in nodes: ob = self.getLinkObj(node) if ob is not None: try: message += '[%s: %i]' % (node, ob.packHistory()) except: message += '[%s: %s]' % (node, 'No history to pack') message = self.getZMILangStr('MSG_CHANGED') + message # Properties. # ----------- elif key == 'properties': # Save. # ------ if btn == 'BTN_SAVE': # Autocommit & Nodes. old_autocommit = self.autocommit new_autocommit = REQUEST.get('workflow', 0) == 0 self.revision = REQUEST.get('revision', '0.0.0') self.autocommit = new_autocommit self.nodes = standard.string_list(REQUEST.get('nodes', '')) if old_autocommit == 0 and new_autocommit == 1: self.doAutocommit(lang, REQUEST) message = self.getZMILangStr('MSG_CHANGED') # Clear. # ------ elif btn == 'BTN_CLEAR': self.doAutocommit(lang, REQUEST) self.autocommit = 1 self.activities = [] self.transitions = [] message = self.getZMILangStr('MSG_CHANGED') # Export. # ------- elif btn == 'BTN_EXPORT': return exportXml(self, REQUEST, RESPONSE) # Import. # ------- elif btn == 'BTN_IMPORT': f = REQUEST['file'] if f: filename = f.filename xml = f else: filename = REQUEST.get('init') xml = open(_fileutil.getOSPath(filename), 'rb') self.importXml(xml) message = self.getZMILangStr('MSG_IMPORTED') % ('<i>%s</i>' % filename) # Return with message. message = standard.url_quote(message) return RESPONSE.redirect( 'manage_main?lang=%s&key=%s&manage_tabs_message=%s#_properties' % (lang, key, message))
def urlQuote(self, s): return standard.url_quote(s)