2 from ZTUtils
import SimpleTreeMaker
3 stm
= SimpleTreeMaker()
4 def replaceXMLEntities(text
) :
5 for c
, ent
in (('<', '<'), ('>', '>'), ('&', '&')) :
6 text
= text
.replace(c
, ent
)
9 from string
import maketrans
10 rmBadAttrChars
= maketrans('<&"', ' ')
12 filter = filter.split(',')
15 context
.REQUEST
.RESPONSE
.setHeader('content-type', 'text/xml; charset=utf-8')
17 for ob
in context
.listNearestFolderContents(contentFilter
={'portal_type':filter}) :
18 icon
= context
.restrictedTraverse(ob
.getIcon())
20 if not getattr(ob
, 'isPortalContent', False) :
21 state
= ob
.listNearestFolderContents(contentFilter
={'portal_type':filter}) and "-1" or "0"
22 row
= '<row name="%(name)s" url="%(url)s" icon="%(icon)s" height="%(height)d" width="%(width)d" state="%(state)s" description="%(description)s">%(title)s</row>' % {
23 'name' : stm
.node(ob
).id,
24 'url' : ob
.absolute_url(),
25 'title' : ' '+replaceXMLEntities(ob
.title_or_id()),
26 'description' : ob
.Description().translate(rmBadAttrChars
),
27 'icon' : icon
.absolute_url(),
28 'height' : icon
.height
,