-
Notifications
You must be signed in to change notification settings - Fork 0
/
zmscustom.py
551 lines (498 loc) · 24.5 KB
/
zmscustom.py
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
# -*- coding: utf-8 -*-
################################################################################
# zmscustom.py
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
################################################################################
# Imports.
from AccessControl import ClassSecurityInfo
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
import Globals
import copy
import sys
import time
import urllib
# Product Imports.
from zmscontainerobject import ZMSContainerObject
import _confmanager
import _fileutil
import standard
import _importable
import _ziputil
# ------------------------------------------------------------------------------
# zmscustom.parseXmlString
# ------------------------------------------------------------------------------
def parseXmlString(self, file):
standard.writeBlock( self, '[parseXmlString]')
message = ''
REQUEST = self.REQUEST
lang = REQUEST.get( 'lang', self.getPrimaryLanguage())
v = self.parseXmlString(file)
metaObj = self.getMetaobj(self.meta_id)
res_id = metaObj['attrs'][0]['id']
res_abs = self.getObjProperty(res_id,REQUEST)
res_abs.extend(v)
self.setObjStateModified(REQUEST)
self.setObjProperty(res_id,res_abs,lang)
self.onChangeObj(REQUEST)
return message
################################################################################
################################################################################
###
### Constructor
###
################################################################################
################################################################################
manage_addZMSCustomForm = PageTemplateFile('manage_addzmscustomform', globals())
def manage_addZMSCustom(self, meta_id, lang, _sort_id, REQUEST, RESPONSE):
""" manage_addZMSCustom """
message = ''
messagekey = 'manage_tabs_message'
t0 = time.time()
target = self.absolute_url()
if REQUEST['btn'] == self.getZMILangStr('BTN_INSERT'):
# Create
id_prefix = standard.id_prefix(REQUEST.get('id_prefix','e'))
new_id = self.getNewId(id_prefix)
globalAttr = self.dGlobalAttrs.get(meta_id,self.dGlobalAttrs['ZMSCustom'])
constructor = globalAttr.get('obj_class',self.dGlobalAttrs['ZMSCustom']['obj_class'])
obj = constructor(new_id,_sort_id+1,meta_id)
self._setObject(obj.id, obj)
metaObj = self.getMetaobj( meta_id)
redirect_self = bool( REQUEST.get( 'redirect_self', 0)) or REQUEST.get( 'btn', '') == '' or metaObj['type'] == 'ZMSRecordSet'
for attr in metaObj['attrs']:
attr_type = attr['type']
redirect_self = redirect_self or attr_type in self.getMetaobjIds()+['*']
redirect_self = redirect_self and not REQUEST.get('btn','') in [ self.getZMILangStr('BTN_CANCEL'), self.getZMILangStr('BTN_BACK')]
obj = getattr(self,obj.id)
try:
# Object State
obj.setObjStateNew(REQUEST)
# Init Coverage
coverage = self.getDCCoverage(REQUEST)
if coverage.find('local.')==0:
obj.setObjProperty('attr_dc_coverage',coverage)
else:
obj.setObjProperty('attr_dc_coverage','global.'+lang)
# Change Properties
obj.changeProperties(lang)
# Normalize Sort-Ids
self.normalizeSortIds(id_prefix)
# Message
message = self.getZMILangStr('MSG_INSERTED')%obj.display_type(REQUEST)
except:
message = standard.writeError(self,"[manage_addZMSCustom]")
messagekey = 'manage_tabs_error_message'
message += ' (in '+str(int((time.time()-t0)*100.0)/100.0)+' secs.)'
# Return with message.
if redirect_self:
target = '%s/%s'%(target,obj.id)
target = REQUEST.get( 'manage_target', '%s/manage_main'%target)
target = self.url_append_params( target, { 'lang': lang, messagekey: message})
target = '%s#zmi_item_%s'%( target, obj.id)
RESPONSE.redirect(target)
else:
RESPONSE.redirect('%s/manage_main?lang=%s'%(target,lang))
def containerFilter(container):
return container.meta_type.startswith('ZMS')
################################################################################
################################################################################
###
### Class
###
################################################################################
################################################################################
class ZMSCustom(ZMSContainerObject):
# Create a SecurityInfo for this class. We will use this
# in the rest of our class definition to make security
# assertions.
security = ClassSecurityInfo()
# Properties.
# -----------
meta_type = "ZMSCustom"
# Management Options.
# -------------------
def manage_options(self):
pc = 'e' in map(lambda x:x['id'],self.getMetaobjAttrs(self.meta_id,types=['*']))
opts = []
opts.append({'label': 'TAB_EDIT', 'action': 'manage_main'})
if pc:
opts.append({'label': 'TAB_PROPERTIES', 'action': 'manage_properties'})
opts.append({'label': 'TAB_IMPORTEXPORT', 'action': 'manage_importexport'})
opts.append({'label': 'TAB_REFERENCES', 'action': 'manage_RefForm'})
if not self.getAutocommit() or self.getHistory():
opts.append({'label': 'TAB_HISTORY', 'action': 'manage_UndoVersionForm'})
for metaObjAttr in filter(lambda x:x['id'].startswith('manage_tab'),self.getMetaobjAttrs(self.meta_id)):
opt = {'label': metaObjAttr['name'], 'action': 'manage_executeMetacmd', 'alias':metaObjAttr['id'], 'params':{'id':metaObjAttr['id']}}
opts.append(opt)
for metaCmd in self.getMetaCmds(self,'tab'):
opt = {'label': metaCmd['name'], 'action': 'manage_executeMetacmd', 'alias':metaCmd['id'], 'params':{'id':metaCmd['id']}}
opts.append(opt)
return tuple(opts)
# Management Permissions.
# -----------------------
__authorPermissions__ = (
'manage','manage_main','manage_main_iframe','manage_container','manage_workspace',
'manage_menu',
'manage_addZMSModule',
'manage_changeRecordSet',
'manage_properties','manage_changeProperties','manage_changeTempBlobjProperty',
'manage_deleteObjs','manage_undoObjs','manage_moveObjUp','manage_moveObjDown','manage_moveObjToPos',
'manage_cutObjects','manage_copyObjects','manage_pasteObjs',
'manage_ajaxDragDrop','manage_ajaxZMIActions',
'manage_UndoVersionForm','manage_UndoVersion',
'manage_wfTransition', 'manage_wfTransitionFinalize',
'manage_userForm', 'manage_user',
'manage_importexport', 'manage_import', 'manage_export',
'manage_executeMetacmd',
)
__viewPermissions__ = (
'manage_ajaxGetChildNodes','manage_get_node_json',
)
__ac_permissions__=(
('ZMS Author', __authorPermissions__),
('View', __viewPermissions__),
)
# Templates.
# ----------
manage_properties = PageTemplateFile('zpt/ZMSObject/manage_main', globals())
manage_main_iframe = PageTemplateFile('zpt/ZMSObject/manage_main_iframe', globals())
manage_menu = PageTemplateFile('zpt/object/manage_menu', globals())
metaobj_recordset_main_grid = PageTemplateFile('zpt/ZMSRecordSet/main_grid', globals())
metaobj_recordset_main = PageTemplateFile('zpt/ZMSRecordSet/main', globals())
metaobj_recordset_input_fields = PageTemplateFile('zpt/ZMSRecordSet/input_fields', globals())
"""
############################################################################
###
### Constructor
###
############################################################################
"""
############################################################################
# ZMSCustom.__init__:
#
# Constructor (initialise a new instance of ZMSCustom).
############################################################################
def __init__(self, id='', sort_id=0, meta_id=None):
""" ZMSCustom.__init__ """
ZMSContainerObject.__init__(self,id,sort_id)
self.meta_id = standard.nvl(meta_id,self.meta_type)
############################################################################
###
### ZMSRecordSet
###
############################################################################
"""
Initialize record-set.
@return: list of records
@rtype: C{list}
"""
def recordSet_Init(self, REQUEST):
request = self.REQUEST
metaObj = self.getMetaobj(self.meta_id)
res_id = metaObj['attrs'][0]['id']
res = self.getObjProperty(res_id,REQUEST)
REQUEST.set('res_abs',res)
REQUEST.set('res',res)
return res
"""
Filter record-set.
@return: filtered list of records
@rtype: C{list}
"""
def recordSet_Filter(self, REQUEST):
metaObj = self.getMetaobj(self.meta_id)
res = REQUEST['res']
# foreign key
filterattr='fk_key'
filtervalue='fk_val'
sessionattr='%s_%s'%(filterattr,self.id)
sessionvalue='%s_%s'%(filtervalue,self.id)
standard.set_session_value(self,sessionattr,REQUEST.form.get(filterattr,standard.get_session_value(self,sessionattr,'')))
standard.set_session_value(self,sessionvalue,REQUEST.form.get(filtervalue,standard.get_session_value(self,sessionvalue,'')))
if REQUEST.get('btn','')==self.getZMILangStr('BTN_RESET'):
standard.set_session_value(self,sessionattr,'')
standard.set_session_value(self,sessionvalue,'')
if standard.get_session_value(self,sessionattr,'') != '' and \
standard.get_session_value(self,sessionvalue,''):
res = standard.filter_list(res,standard.get_session_value(self,sessionattr),standard.get_session_value(self,sessionvalue),'==')
masterType = filter(lambda x: x['id']==standard.get_session_value(self,sessionattr),metaObj['attrs'][1:])[0]['type']
master = filter(lambda x: x.meta_id==masterType,self.getParentNode().objectValues(['ZMSCustom']))[0]
masterMetaObj = self.getMetaobj(masterType)
masterAttrs = masterMetaObj['attrs']
masterRows = master.getObjProperty(masterAttrs[0]['id'],REQUEST)
masterRows = standard.filter_list(masterRows,masterAttrs[1]['id'],standard.get_session_value(self,sessionvalue),'==')
REQUEST.set('masterMetaObj',masterMetaObj)
REQUEST.set('masterRow',masterRows[0])
# init filter from request.
for filterIndex in range(100):
for filterStereotype in ['attr','op','value']:
requestkey = 'filter%s%i'%(filterStereotype,filterIndex)
sessionkey = '%s_%s'%(requestkey,self.id)
requestvalue = REQUEST.form.get(requestkey,standard.get_session_value(self,sessionkey,''))
if REQUEST.get('btn','')==self.getZMILangStr('BTN_RESET'):
requestvalue = ''
REQUEST.set(requestkey,requestvalue)
standard.set_session_value(self,sessionkey,requestvalue)
standard.set_session_value(self,'qfilters_%s'%self.id,REQUEST.form.get('qfilters',standard.get_session_value(self,'qfilters_%s'%self.id,1)))
# apply filter
for filterIndex in range(100):
suffix = '%i_%s'%(filterIndex,self.id)
sessionattr = standard.get_session_value(self,'filterattr%s'%suffix,'')
sessionop = standard.get_session_value(self,'filterop%s'%suffix,'%')
sessionvalue = standard.get_session_value(self,'filtervalue%s'%suffix,'')
if sessionattr and sessionvalue:
metaObjAttr = self.getMetaobjAttr(self.meta_id,sessionattr)
sessionvalue = self.formatObjAttrValue(metaObjAttr,sessionvalue,REQUEST['lang'])
res = standard.filter_list(res,sessionattr,sessionvalue,sessionop)
REQUEST.set('res',res)
return res
"""
Sort record-set.
@return: sorted list of records
@rtype: C{list}
"""
def recordSet_Sort(self, REQUEST=None):
request = self.REQUEST
metaObj = self.getMetaobj(self.meta_id)
res = request['res']
if 'sort_id' in map(lambda x:x['id'],metaObj['attrs']):
l = map(lambda x:(x.get('sort_id',1),x),res)
# Sort (FK).
for metaObjAttr in metaObj['attrs'][1:]:
if metaObjAttr.get('type','') in self.getMetaobjIds():
d = {}
# FK-id for primary-sort.
map(lambda x:self.operator_setitem(d,x.get(metaObjAttr['id']),x.get(metaObjAttr['id'])),res)
for fkContainer in self.getParentNode().getChildNodes(request,metaObjAttr['type']):
fkMetaObj = self.getMetaobj(fkContainer.meta_id)
fkMetaObjAttrIdRecordSet = fkMetaObj['attrs'][0]['id']
if 'sort_id' in map(lambda x:x['id'],metaObj['attrs']):
fkMetaObjRecordSet = fkContainer.attr(fkMetaObjAttrIdRecordSet)
fkMetaObjIdId = self.getMetaobjAttrIdentifierId(fkContainer.meta_id)
# FK-sort_id for primary-sort.
map(lambda x:self.operator_setitem(d,x.get(fkMetaObjIdId),x.get('sort_id')),fkMetaObjRecordSet)
# Add primary-sort.
l = map(lambda x:((d.get(x[1].get(metaObjAttr['id'])),x[0]),x[1]),l)
break
l.sort()
res = map(lambda x:x[1],l)
else:
qorder = request.get('qorder','')
qorderdir = 'asc'
if qorder == '':
skiptypes = [ 'file', 'image']+self.getMetaobjManager().valid_xtypes+self.getMetaobjIds()
for attr in metaObj['attrs'][1:]:
if attr.get('type','') not in skiptypes and \
attr.get('name','') != '' and \
attr.get('custom','') != '':
qorder = attr['id']
if attr.get('type','') in ['date','datetime','time']:
qorderdir = 'desc'
break
if qorder:
qorderdir = request.get('qorderdir',qorderdir)
res = self.sort_list(res,qorder,qorderdir)
request.set('qorder',qorder)
request.set('qorderdir',qorderdir)
request.set('res',res)
return res
# --------------------------------------------------------------------------
# ZMSCustom.recordSet_Export:
# --------------------------------------------------------------------------
security.declareProtected('View', 'recordSet_Export')
def recordSet_Export(self, lang, qorder, qorderdir, qindex=[], REQUEST=None, RESPONSE=None):
"""
Export record-set to XML.
"""
self.recordSet_Init(REQUEST)
self.recordSet_Filter(REQUEST)
self.recordSet_Sort(REQUEST)
res=REQUEST['res']
value = []
for i in range(len(res)):
if len(qindex)==0 or str(i) in qindex:
value.append(res[i])
RESPONSE.setHeader('Content-Type','text/xml; charset=utf-8')
RESPONSE.setHeader('Content-Disposition','attachment;filename="recordSet_Export.xml"')
export = self.getXmlHeader() + self.toXmlString(value,True)
return export
# --------------------------------------------------------------------------
# ZMSCustom.getEntityRecordHandler
# --------------------------------------------------------------------------
def getEntityRecordHandler(self, id):
class EntityRecordHandler:
def __init__(self, parent, id):
self.parent = parent
self.id = id
self.fk = {}
metaObjIds = parent.getMetaobjIds()
for k in parent.getMetaobjAttrIds(id):
metaObjAttr = parent.getMetaobjAttr(id,k)
if metaObjAttr['type'] in metaObjIds:
fkMetaObj = parent.getMetaobj(metaObjAttr['type'])
fkMetaObjIdId = fkMetaObj['attrs'][0]['id']
for fkContainer in parent.getParentNode().getChildNodes(self.parent.REQUEST,metaObjAttr['type']):
fkMetaObj = parent.getMetaobj(fkContainer.meta_id);
fkMetaObjAttrIdRecordSet = fkMetaObj['attrs'][0]['id'];
fkMetaObjRecordSet = fkContainer.attr(fkMetaObjAttrIdRecordSet);
fkMetaObjIdId = parent.getMetaobjAttrIdentifierId(fkContainer.meta_id)
self.fk[k] = {'fkMetaObj':fkMetaObj,'fkMetaObjRecordSet':fkMetaObjRecordSet,'fkMetaObjIdId':fkMetaObjIdId}
handle_record__roles__ = None
def handle_record(self, r):
d = {}
for k in r.keys():
v = r[k]
if k in self.fk.keys():
fk = self.fk[k]
fkMetaObj = fk['fkMetaObj']
fkMetaObjRecordSet = fk['fkMetaObjRecordSet']
fkMetaObjIdId = fk['fkMetaObjIdId']
for fkMetaObjRecord in filter(lambda x:x.get(fkMetaObjIdId)==v,fkMetaObjRecordSet):
fkMetaObjAttrs = filter(lambda x:x['type']=='string' and fkMetaObjRecord.get(x['id'],'')!='',fkMetaObj['attrs'])
v = ', '.join(map(lambda x:str(fkMetaObjRecord.get(x['id'])),fkMetaObjAttrs))
d[k] = v
return d
return EntityRecordHandler(self,id)
############################################################################
# ZMSCustom.manage_changeRecordSet:
#
# Change record-set.
############################################################################
def manage_changeRecordSet(self, lang, btn, action, REQUEST, RESPONSE):
""" ZMSCustom.manage_changeRecordSet """
message = ''
messagekey = 'manage_tabs_message'
target = REQUEST.get('target','manage_main')
params = {'lang':lang}
t0 = time.time()
if action or btn and btn not in [ self.getZMILangStr('BTN_CANCEL'), self.getZMILangStr('BTN_BACK')]:
try:
##### Object State #####
self.setObjStateModified(REQUEST)
metaObj = self.getMetaobj(self.meta_id)
metaObjAttrIds = self.getMetaobjAttrIds(self.meta_id)
res_abs = self.recordSet_Init(REQUEST)
if action == 'insert':
row = {}
row['_created_uid'] = REQUEST['AUTHENTICATED_USER'].getUserName()
row['_created_dt'] = standard.getDateTime( time.time())
row['_change_uid'] = REQUEST['AUTHENTICATED_USER'].getUserName()
row['_change_dt'] = standard.getDateTime( time.time())
for metaObjAttr in metaObj['attrs'][1:]:
objAttr = self.getObjAttr(metaObjAttr['id'])
objAttrName = self.getObjAttrName(objAttr,lang)
if metaObjAttr['type'] in self.metaobj_manager.valid_types or \
metaObjAttr['type'] not in self.metaobj_manager.valid_xtypes+self.metaobj_manager.valid_zopetypes:
value = self.formatObjAttrValue(objAttr,REQUEST.get(objAttrName),lang)
try: del value['aq_parent']
except: pass
if metaObjAttr['id'] == 'sort_id' and value is None:
value = len(res_abs)
row[metaObjAttr['id']] = value
res_abs.append(row)
params['qindex'] = len(res_abs)-1
message = self.getZMILangStr('MSG_INSERTED')%self.getZMILangStr('ATTR_RECORD')
elif action == 'update':
row = res_abs[REQUEST['qindex']]
row['_change_uid'] = REQUEST['AUTHENTICATED_USER'].getUserName()
row['_change_dt'] = standard.getDateTime( time.time())
for metaObjAttr in metaObj['attrs'][1:]:
objAttr = self.getObjAttr(metaObjAttr['id'])
objAttrName = self.getObjAttrName(objAttr,lang)
if metaObjAttr['type'] in self.metaobj_manager.valid_types or \
metaObjAttr['type'] not in self.metaobj_manager.valid_xtypes+self.metaobj_manager.valid_zopetypes:
set,value = True,self.formatObjAttrValue(objAttr,REQUEST.get(objAttrName),lang)
try: del value['aq_parent']
except: pass
if value is None and metaObjAttr['id'] == 'sort_id':
value = len(res_abs)
if value is None and metaObjAttr['type'] in ['file','image'] and int(REQUEST.get('del_%s'%objAttrName,0)) == 0:
set = False
if set:
row[metaObjAttr['id']] = value
res_abs[REQUEST['qindex']] = row
params['qindex'] = REQUEST['qindex']
message = self.getZMILangStr('MSG_CHANGED')
elif action == 'delete':
rows = map(lambda x: res_abs[int(x)], REQUEST.get('qindices',[]))
for row in rows:
del res_abs[res_abs.index(row)]
message = self.getZMILangStr('MSG_DELETED')%len(rows)
elif action == 'duplicate':
rows = [copy.deepcopy(res_abs[int(x)]) for x in REQUEST.get('qindices',[])]
_change_uid = REQUEST['AUTHENTICATED_USER'].getUserName()
_change_dt = standard.getDateTime( time.time())
identifiers = [x for x in metaObj['attrs'][1:] if x['type'] == 'identifier']
for row in rows:
row['_change_uid'] = _change_uid
row['_change_dt'] = _change_dt
for identifier in identifiers:
row[identifier['id']] = self.getNewId()
res_abs += rows
message = self.getZMILangStr('MSG_INSERTED')%('%i %s'%(len(rows),self.getZMILangStr('ATTR_RECORDS')))
elif action == 'move':
for row in res_abs:
row['sort_id'] = row.get('sort_id',1)*10
pos = REQUEST['pos']
newpos = REQUEST['newpos']
row = res_abs[REQUEST['qindex']]
row['sort_id'] = row['sort_id']+(newpos-pos)*15
params['qindex'] = REQUEST['qindex']+(newpos-pos)
message = self.getZMILangStr('MSG_MOVEDOBJTOPOS')%('%s %i'%(self.getZMILangStr('ATTR_RECORD'),pos),newpos)
# Normalize sort-ids.
if 'sort_id' in metaObjAttrIds:
res_abs = standard.sort_list(res_abs,'sort_id')
for i in range(len(res_abs)):
row = res_abs[i]
row['sort_id'] = i+1
self.setObjProperty(metaObj['attrs'][0]['id'],res_abs,lang)
##### VersionManager ####
self.onChangeObj(REQUEST)
except:
message = standard.writeError(self,"[manage_changeProperties]")
messagekey = 'manage_tabs_error_message'
message += ' (in '+str(int((time.time()-t0)*100.0)/100.0)+' secs.)'
# Return with message.
params[messagekey] = message
target = self.url_append_params( target, params)
return REQUEST.RESPONSE.redirect(target)
############################################################################
# ZMSCustom.manage_import:
#
# Import XML-file.
############################################################################
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 = urllib.quote(message)
return RESPONSE.redirect('manage_main?lang=%s&manage_tabs_message=%s'%(lang,message))
else:
return ob
# call this to initialize framework classes, which
# does the right thing with the security assertions.
Globals.InitializeClass(ZMSCustom)
################################################################################