-
Notifications
You must be signed in to change notification settings - Fork 0
/
zmslinkelement.py
727 lines (623 loc) · 28.7 KB
/
zmslinkelement.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
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
# -*- coding: utf-8 -*-
################################################################################
# zmslinkelement.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
import Globals
import sys
import urllib
# Product Imports.
from zmscontainerobject import ZMSContainerObject
from zmscustom import ZMSCustom
from zmsobject import ZMSObject
from zmsproxyobject import ZMSProxyObject
import standard
import _confmanager
import _xmllib
import _zreferableitem
"""
################################################################################
# class ConstraintViolation(Exception):
#
# General exception class to indicate constraint violations.
################################################################################
"""
class ConstraintViolation(Exception): pass
################################################################################
################################################################################
###
### Class
###
################################################################################
################################################################################
class ZMSLinkElement(ZMSCustom):
# 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 = meta_id = "ZMSLinkElement"
# Management Options.
# -------------------
manage_options = (
{'label': 'TAB_EDIT', 'action': 'manage_main'},
{'label': 'TAB_HISTORY', 'action': 'manage_UndoVersionForm'},
)
# Management Permissions.
# -----------------------
__authorPermissions__ = (
'manage','manage_main','manage_main_iframe','manage_workspace',
'manage_changeProperties','manage_changeTempBlobjProperty',
'manage_moveObjUp','manage_moveObjDown','manage_moveObjToPos',
'manage_cutObjects','manage_copyObjects','manage_pasteObjs',
'manage_ajaxDragDrop','manage_ajaxZMIActions',
'manage_userForm','manage_user',
)
__viewPermissions__ = (
'manage_ajaxGetChildNodes','manage_get_node_json',
)
__ac_permissions__=(
('ZMS Author', __authorPermissions__),
('View', __viewPermissions__),
)
############################################################################
#
# Constructor
#
############################################################################
# --------------------------------------------------------------------------
# ZMSLinkElement.getSelf:
# --------------------------------------------------------------------------
def getSelfPROXY(self, proxy, meta_type=None):
return ZMSObject.getSelf( proxy, meta_type)
def getSelf(self, meta_type=None):
proxy = self.getProxy()
rtn = self.getSelfPROXY( proxy, meta_type)
return rtn
# --------------------------------------------------------------------------
# ZMSLinkElement.getEmbedType:
# --------------------------------------------------------------------------
def getEmbedType(self):
embed_type = self.getObjAttrValue( self.getObjAttr( 'attr_type'), self.REQUEST)
if embed_type in [ 'embed', 'recursive', 'remote']:
ref_obj = self.getRefObj()
if ref_obj is not None and ref_obj.isAncestor( self):
embed_type = 'cyclic' # Error!
return embed_type
# --------------------------------------------------------------------------
# ZMSLinkElement.isEmbedded:
# --------------------------------------------------------------------------
def isEmbedded(self, REQUEST):
rtn = self.getEmbedType() in [ 'embed', 'recursive', 'remote']
return rtn
# --------------------------------------------------------------------------
# ZMSLinkElement.isEmbeddedRecursive:
# --------------------------------------------------------------------------
def isEmbeddedRecursive(self, REQUEST):
rtn = self.getEmbedType() in [ 'recursive']
return rtn
############################################################################
###
### Properties
###
############################################################################
############################################################################
# ZMSLinkElement.manage_changeProperties:
#
# Change Linkelement properties.
############################################################################
def manage_changeProperties(self, lang, REQUEST, RESPONSE):
""" ZMSLinkElement.manage_changeProperties """
target_ob = self.getParentNode()
if REQUEST.get('menulock',0) == 1:
# Remain in Current Menu
target_ob = self
target = REQUEST.get( 'manage_target', '%s/manage_main'%target_ob.absolute_url())
message = ''
if REQUEST.get('btn','') not in [ self.getZMILangStr('BTN_CANCEL'), self.getZMILangStr('BTN_BACK')]:
try:
##### Object State ####
self.setObjStateModified(REQUEST)
##### Properties ####
for key in self.getObjAttrs().keys():
obj_attr = self.getObjAttr(key)
if obj_attr['xml']:
self.setReqProperty(key,REQUEST)
##### VersionManager ####
self.onChangeObj(REQUEST)
##### Success Message ####
message = self.getZMILangStr('MSG_CHANGED')
##### Failure Message ####
except ConstraintViolation:
target = REQUEST.get( 'manage_target', '%s/manage_main'%self.absolute_url())
message = "[ConstraintViolation]: " + str( sys.exc_value)
# Return with message.
target = self.url_append_params( target, { 'lang': lang, 'manage_tabs_message': message})
target = '%s#zmi_item_%s'%( target, self.id)
return RESPONSE.redirect( target)
# --------------------------------------------------------------------------
# ZMSLinkElement.getRef:
# --------------------------------------------------------------------------
def getRef(self):
coverage = self.getDCCoverage()
req = {'preview':'preview','lang':coverage[coverage.find('.')+1:]}
ref = self.getObjAttrValue( self.getObjAttr( 'attr_ref'), req)
return ref
# --------------------------------------------------------------------------
# ZMSLinkElement.getRefObj:
# --------------------------------------------------------------------------
def getRefObj(self):
ref_obj = self.getLinkObj(self.getRef())
if ref_obj == self:
ref_obj = None
if ref_obj is not None and ref_obj.meta_type == 'ZMSLinkElement':
ref_obj = ref_obj.getRefObj()
return ref_obj
# --------------------------------------------------------------------------
# ZMSLinkElement.getRemoteObj:
# --------------------------------------------------------------------------
def getRemoteObj(self):
value = None
ref = self.getRef()
try:
value = self.http_import( ref + '/ajaxGetNode?lang=%s'%lang)
value = _xmllib.xmlParse( value)
except:
standard.writeError(self,'[getRemoteObj]: can\'t embed from remote: ref=%s'%ref)
return value
# --------------------------------------------------------------------------
# ZMSLinkElement.isMetaType:
# --------------------------------------------------------------------------
def isMetaTypePROXY(self, proxy, meta_type, REQUEST={'preview':'preview'}):
if proxy != self and proxy is not None and self.isEmbeddedRecursive( self.REQUEST):
b = proxy.isMetaType( meta_type, REQUEST)
else:
b = False
if not (self.NOREF == meta_type or (type(meta_type) is list and self.NOREF in meta_type)):
b = b or ZMSObject.isMetaType(self,meta_type,REQUEST)
ref_obj = self.getRefObj()
if ref_obj is not None and self.isEmbedded(REQUEST):
if not (self.NORESOLVEREF == meta_type or (type(meta_type) is list and self.NORESOLVEREF in meta_type)):
b = b or ref_obj.isMetaType(meta_type,REQUEST)
return b
def isMetaType(self, meta_type, REQUEST={'preview':'preview'}):
proxy = self.getProxy()
rtn = self.isMetaTypePROXY( proxy, meta_type, REQUEST)
return rtn
# --------------------------------------------------------------------------
# ZMSLinkElement.getLevel:
# --------------------------------------------------------------------------
def getLevelPROXY(self, proxy):
if proxy != self and proxy is not None and self.isEmbeddedRecursive( self.REQUEST):
rtn = proxy.getLevel()
else:
rtn = self.getParentNode().getLevel() + 1
return rtn
def getLevel(self):
proxy = self.getProxy()
rtn = self.getLevelPROXY( proxy)
return rtn
# --------------------------------------------------------------------------
# ZMSLinkElement.getParentNode:
# --------------------------------------------------------------------------
def getParentNodePROXY(self, proxy):
if proxy != self and proxy is not None and self.isEmbeddedRecursive( self.REQUEST):
rtn = proxy.getParentNode()
else:
rtn = getattr( self, 'aq_parent', getattr( self, 'base', None))
return rtn
getParentNode__roles__ = None
def getParentNode(self):
"""
The parent of this node.
All nodes except root may have a parent.
"""
proxy = self.getProxy()
rtn = self.getParentNodePROXY( proxy)
return rtn
# --------------------------------------------------------------------------
# ZMSLinkElement.getTitlealt:
# --------------------------------------------------------------------------
def getTitlealtPROXY(self, proxy, REQUEST):
if proxy != self and proxy is not None and self.isEmbeddedRecursive( REQUEST):
rtn = proxy.getTitlealt( REQUEST)
else:
rtn = self.getObjProperty('titlealt',REQUEST)
if len(rtn) == 0:
ref_obj = self.getRefObj()
if ref_obj is None:
rtn = super(ZMSLinkElement,self).getTitlealt(REQUEST)
else:
rtn = ref_obj.getTitlealt(REQUEST)
return rtn
def getTitlealt(self, REQUEST):
rtn = ''
if self.getEmbedType() == 'remote':
remote_obj = self.getRemoteObj()
if type( remote_obj) is list:
for node in _xmllib.xmlNodeSet( remote_obj, 'titlealt'):
rtn = node['cdata']
else:
proxy = self.getProxy()
rtn = self.getTitlealtPROXY( proxy, REQUEST)
if len(rtn) == 0:
rtn = self.display_type(REQUEST)
return rtn
# --------------------------------------------------------------------------
# ZMSLinkElement.getTitle:
# --------------------------------------------------------------------------
def getTitlePROXY(self, proxy, REQUEST):
if proxy != self and proxy is not None and self.isEmbeddedRecursive( REQUEST):
rtn = proxy.getTitle( REQUEST)
else:
rtn = self.getObjProperty('title',REQUEST)
if len(rtn) == 0:
ref_obj = self.getRefObj()
if ref_obj is None:
rtn = super(ZMSLinkElement,self).getTitle(REQUEST)
else:
rtn = ref_obj.getTitle(REQUEST)
return rtn
def getTitle(self, REQUEST):
rtn = ''
if self.getEmbedType() == 'remote':
remote_obj = self.getRemoteObj()
if type( remote_obj) is list:
for node in _xmllib.xmlNodeSet( remote_obj, 'title'):
rtn = node['cdata']
else:
proxy = self.getProxy()
rtn = self.getTitlePROXY( proxy, REQUEST)
if len(rtn) == 0:
rtn = self.display_type(REQUEST)
return rtn
# --------------------------------------------------------------------------
# ZMSLinkElement.display_icon:
# --------------------------------------------------------------------------
def display_icon(self, REQUEST, meta_type=None, key='icon', zpt=True):
zmsobject = self
if self.isEmbedded(REQUEST):
ref_obj = self.getRefObj()
if ref_obj is not None:
zmsobject = ref_obj
return ZMSObject.display_icon(zmsobject,REQUEST=REQUEST,meta_type=meta_type,key=key,zpt=zpt)
# --------------------------------------------------------------------------
# ZMSLinkElement.isActive:
# --------------------------------------------------------------------------
def isActive(self, REQUEST):
active = super(ZMSLinkElement,self).isActive(REQUEST)
if self.getEmbedType() == 'remote':
remote_obj = self.getRemoteObj()
if type( remote_obj) is list:
rtnVal = remote_obj[1]['attrs']['active'] in ['1','True']
else:
ref_obj = self.getRefObj()
if ref_obj is not None:
active = active and ref_obj.isActive(REQUEST)
return active
# --------------------------------------------------------------------------
# ZMSLinkElement.isPageContainer:
# --------------------------------------------------------------------------
def isPageContainer(self):
return False
# --------------------------------------------------------------------------
# ZMSLinkElement.isPage
# --------------------------------------------------------------------------
def isPage(self):
rtnVal = False
if self.getEmbedType() == 'remote':
remote_obj = self.getRemoteObj()
if type( remote_obj) is list:
rtnVal = remote_obj[1]['attrs']['is_page'] in ['1','True']
else:
if self.isEmbedded( self.REQUEST):
ref_obj = self.getRefObj()
if ref_obj is not None:
rtnVal = rtnVal or ref_obj.isPage()
return rtnVal
# --------------------------------------------------------------------------
# ZMSLinkElement.isPageElement
# --------------------------------------------------------------------------
def isPageElement(self):
rtnVal = False
if self.getEmbedType() == 'remote':
remote_obj = self.getRemoteObj()
if type( remote_obj) is list:
rtnVal = remote_obj[1]['attrs']['is_pageelement'] in ['1','True']
else:
if self.isEmbedded( self.REQUEST):
ref_obj = self.getRefObj()
if ref_obj is not None:
rtnVal = rtnVal or ref_obj.isPageElement()
else:
rtnVal = rtnVal or True
elif self.getObjProperty('align',self.REQUEST) not in ['','NONE']:
rtnVal = rtnVal or True
return rtnVal
# --------------------------------------------------------------------------
# ZMSLinkElement.getType
#
# Overrides getType of zmscustom.ZMSCustom.
# --------------------------------------------------------------------------
def getTypePROXY(self, proxy):
rtn = 'ZMSObject'
if proxy != self and proxy is not None and self.isEmbeddedRecursive( self.REQUEST):
rtn = proxy.getType()
else:
ref_obj = self.getRefObj()
if ref_obj is not None:
rtn = ref_obj.getType()
return rtn
def getType(self):
proxy = self.getProxy()
rtn = self.getTypePROXY( proxy)
return rtn
# --------------------------------------------------------------------------
# ZMSLinkElement.getObjProperty
#
# Overrides getObjProperty of _objattrs.ObjAttrs.
# --------------------------------------------------------------------------
def getObjPropertyPROXY(self, proxy, key, REQUEST={}, default=None):
obj_attr = proxy.getObjAttr( key)
value = proxy.getObjAttrValue( obj_attr, REQUEST)
return value
def getObjProperty(self, key, REQUEST={}, default=None):
value = None
value = self.getObjPropertyPROXY( self, key, REQUEST, default)
# First exit...
if (value is None or value=='' or (value==0 and not type(value) is bool)) and \
key in self.getMetaobjAttrIds( self.meta_id):
value = ZMSObject.getObjProperty( self, key, REQUEST, default)
# Second exit...
if (value is None or value=='' or (value == 0 and not type(value) is bool)) and \
key not in ['active','change_uid','change_dt','work_uid','work_dt','internal_dict','attr_ref','attr_dc_coverage']:
recursive = self.isEmbeddedRecursive( REQUEST)
if recursive:
proxy = self.getProxy()
if proxy != self and proxy is not None:
value = self.getObjPropertyPROXY( proxy, key, REQUEST, default)
else:
ref_obj = self.getRefObj()
if ref_obj != self and ref_obj is not None:
value = self.getObjPropertyPROXY( ref_obj, key, REQUEST, default)
# Last exit...
if (value is None or len(str(value)) == 0 or (value == 0 and not type(value) is bool)):
value = ZMSObject.getObjProperty( self, key, REQUEST, default)
return value
# --------------------------------------------------------------------------
# ZMSLinkElement.getNavItems:
#
# Overrides getNavItems of zmscontainerobject.ZMSContainerObject.
# --------------------------------------------------------------------------
def getNavItemsPROXY(self, proxy, current, REQUEST, opt={}, depth=0):
rtn = []
recursive = self.isEmbeddedRecursive( REQUEST)
if proxy != self and proxy is not None and recursive:
rtn = proxy.getNavItems( current, REQUEST, opt, depth)
else:
ref_obj = self.getRefObj()
if isinstance(ref_obj,ZMSContainerObject):
rtn = super(ZMSLinkElement,self).getNavItems( current, REQUEST, opt, depth)
return rtn
def getNavItems(self, current, REQUEST, opt={}, depth=0):
proxy = self.getProxy()
rtn = self.getNavItemsPROXY( proxy, current, REQUEST, opt, depth)
return rtn
# --------------------------------------------------------------------------
# ZMSLinkElement.getNavElements:
#
# Overrides getNavElements of zmscontainerobject.ZMSContainerObject.
# --------------------------------------------------------------------------
def getNavElementsPROXY(self, proxy, REQUEST, expand_tree=1, current_child=None, subElements=[]):
rtn = []
recursive = self.isEmbeddedRecursive( REQUEST)
if proxy != self and proxy is not None and recursive:
rtn = proxy.getNavElements( REQUEST, expand_tree, current_child, subElements)
else:
ref_obj = self.getRefObj()
if isinstance(ref_obj,ZMSContainerObject):
rtn = super(ZMSLinkElement,self).getNavElements( REQUEST, expand_tree, current_child, subElements)
return rtn
def getNavElements(self, REQUEST, expand_tree=1, current_child=None, subElements=[]):
proxy = self.getProxy()
rtn = self.getNavElementsPROXY( proxy, REQUEST, expand_tree, current_child, subElements)
return rtn
############################################################################
###
### HTML-Presentation
###
############################################################################
# --------------------------------------------------------------------------
# ZMSLinkElement.getHref2IndexHtml:
# --------------------------------------------------------------------------
def getHref2IndexHtmlPROXY(self, proxy, REQUEST, deep=1):
if proxy != self and proxy is not None and self.isEmbeddedRecursive( self.REQUEST):
rtn = proxy.getHref2IndexHtml( REQUEST, deep)
else:
rtn = ZMSObject.getHref2IndexHtml( proxy, REQUEST, deep)
return rtn
def getHref2IndexHtml(self, REQUEST, deep=1):
proxy = self.getProxy()
rtn = self.getHref2IndexHtmlPROXY( proxy, REQUEST, deep)
return rtn
# --------------------------------------------------------------------------
# ZMSLinkElement._getBodyContent:
#
# HTML presentation of link-element.
# --------------------------------------------------------------------------
def _getBodyContent(self, REQUEST):
rtn = ''
if self.getEmbedType() == 'remote':
ref = self.getObjProperty('attr_ref',REQUEST)
try:
rtn += self.http_import( ref+'/ajaxGetBodyContent')
except:
rtn += standard.writeError(self,'[_getBodyContent]: can\'t embed from remote: ref=%s'%ref)
else:
if self.isEmbedded(REQUEST):
REQUEST.set('ZMS_RELATIVATE_URL',False)
proxy = self.getProxy()
if proxy != self and proxy is not None and self.isEmbeddedRecursive( self.REQUEST):
rtn += proxy._getBodyContent(REQUEST)
elif proxy == self and proxy is not None and self.isEmbedded( REQUEST):
ref_obj = self.getRefObj()
if ref_obj is None:
ref = self.getObjProperty('attr_ref',REQUEST)
ref_obj = self.getLinkObj(ref)
if ref_obj is not None and ref_obj != self:
rtn += ref_obj._getBodyContent( REQUEST)
else:
rtn = self._getBodyContentContentEditable(self.metaobj_manager.renderTemplate( self))
if self.isEmbedded(REQUEST):
REQUEST.set('ZMS_RELATIVATE_URL',True)
return rtn
# --------------------------------------------------------------------------
# ZMSLinkElement.renderShort:
#
# Renders short presentation of link-element.
# --------------------------------------------------------------------------
def renderShort(self, REQUEST):
rtn = ''
ref_obj = self.getRefObj()
ref = self.getObjProperty('attr_ref',REQUEST)
if self.getEmbedType() == 'remote':
try:
rtn += self.http_import( ref+'/renderShort')
except:
rtn += standard.writeError(self,'[renderShort]: can\'t embed from remote: ref=%s'%ref)
elif self.isEmbedded(REQUEST):
REQUEST.set('ZMS_RELATIVATE_URL',False)
if ref_obj is None:
ref_obj = self.getLinkObj(ref)
if ref_obj is None or ref_obj.isPage():
rtn += super(ZMSLinkElement,self).renderShort(REQUEST)
elif ref_obj != self:
rtn += ref_obj.renderShort(REQUEST)
REQUEST.set('ZMS_RELATIVATE_URL',True)
else:
rtn += self._getBodyContent( REQUEST)
return rtn
############################################################################
###
### DOM-Methods
###
############################################################################
# --------------------------------------------------------------------------
# ZMSLinkElement.breadcrumbs_obj_path:
# --------------------------------------------------------------------------
def breadcrumbs_obj_pathPROXY(self, proxy, portalMaster=True):
if proxy != self and proxy is not None and self.isEmbeddedRecursive( self.REQUEST):
rtn = proxy.breadcrumbs_obj_path()
else:
rtn = ZMSObject.breadcrumbs_obj_path( proxy, portalMaster)
return rtn
def breadcrumbs_obj_path(self, portalMaster=True):
proxy = self.getProxy()
rtn = self.breadcrumbs_obj_pathPROXY( proxy, portalMaster)
return rtn
# --------------------------------------------------------------------------
# ZMSLinkElement.getTreeNodes:
#
# Returns an empty NodeList that contains all children of this subtree in
# correct order. If none, this is a empty NodeList.
# --------------------------------------------------------------------------
def getTreeNodes(self, REQUEST={}, meta_types=None):
return []
# --------------------------------------------------------------------------
# ZMSLinkElement.initProxy:
# --------------------------------------------------------------------------
def initProxy(self, base, url_base, proxy, recursive=False):
return ZMSProxyObject( self, base, url_base, proxy.id, proxy, recursive)
# --------------------------------------------------------------------------
# ZMSLinkElement.__proxy__:
#
# Returns self or referenced object (if embedded) as ZMSProxyObject
# --------------------------------------------------------------------------
def __proxy__(self):
rtn = self
req = self.REQUEST
if req.get( 'ZMS_PROXY', True):
if req.get( 'URL', '').find( '/manage') < 0 or req.get( 'ZMS_PATH_HANDLER', False):
if self.isEmbeddedRecursive( req):
ref_obj = self.getRefObj()
if ref_obj is not None:
recursive = True
rtn = ZMSProxyObject( self, self.aq_parent, self.absolute_url(), self.id, ref_obj, recursive)
return rtn
# --------------------------------------------------------------------------
# ZMSLinkElement.getProxy:
#
# Returns self or proxy-object from Path-Handler (if embedded) as
# ZMSProxyObject.
# --------------------------------------------------------------------------
def getProxy(self):
rtn = self
req = self.REQUEST
if req.get( 'ZMS_PROXY', True):
rtn = req.get( 'ZMS_PROXY_%s'%self.id, self.__proxy__())
return rtn
# --------------------------------------------------------------------------
# ZMSLinkElement.getChildNodes:
#
# Overrides original method of zmscontainerobject.ZMSContainerObject.
# --------------------------------------------------------------------------
def getChildNodesPROXY(self, proxy, REQUEST={}, meta_types=None, reid=None):
rtn = []
if proxy != self and proxy is not None and self.isEmbeddedRecursive( REQUEST):
recursive = True
rtn = map( lambda x: self.initProxy( proxy, proxy.absolute_url()+'/'+x.id, x, recursive), proxy.getChildNodes( REQUEST, meta_types, reid))
elif proxy == self and proxy is not None and self.isEmbedded( REQUEST):
ref_obj = self.getRefObj()
if ref_obj is not None:
for ob in ref_obj.getChildNodes( REQUEST, meta_types, reid):
if not ob.isPage():
rtn.append( ob)
return rtn
def getChildNodes(self, REQUEST={}, meta_types=None, reid=None):
proxy = self.getProxy()
rtn = self.getChildNodesPROXY( proxy, REQUEST, meta_types, reid)
return rtn
############################################################################
###
### Printable
###
############################################################################
# --------------------------------------------------------------------------
# ZMSLinkElement.printHtml:
#
# Renders printable presentation of a ContainerObject.
# --------------------------------------------------------------------------
def printHtmlPROXY(self, proxy, level, sectionizer, REQUEST, deep=True):
rtn = ''
recursive = self.isEmbeddedRecursive( REQUEST)
if proxy != self and proxy is not None and recursive:
rtn = proxy.printHtml( level, sectionizer, REQUEST, deep)
else:
ref_obj = self.getRefObj()
if ref_obj is not None:
rtn = ref_obj.printHtml( level, sectionizer, REQUEST, deep)
return rtn
def printHtml(self, level, sectionizer, REQUEST, deep=True):
proxy = self.getProxy()
rtn = self.printHtmlPROXY( proxy, level, sectionizer, REQUEST, deep)
return rtn
# call this to initialize framework classes, which
# does the right thing with the security assertions.
Globals.InitializeClass(ZMSLinkElement)
################################################################################