61d0eaee8a18b9b3646c8c5d31d108686710a450
1 ##parameters=command, path, Type=None
2 from Products
.CMFCore
.utils
import getToolByName
3 from Products
.CMFCore
.permissions
import View
4 mtool
= getToolByName(context
, 'portal_membership')
5 checkView
= lambda o
: mtool
.checkPermission(View
, o
)
6 utool
= getToolByName(context
, 'portal_url')
7 portal
= utool
.getPortalObject()
9 def replaceXMLEntities(text
) :
10 for c
, ent
in (('<', '<'), ('>', '>'), ('&', '&')) :
11 text
= text
.replace(c
, ent
)
15 path
= path
.replace('\\', '/')
16 path
= path
.strip('/')
19 for name
in path
.split('/') :
20 ob
= getattr(ob
, name
)
24 if ob
.isPrincipiaFolderish
:
25 if Type
== 'Image' : filter = {'portal_type' : ['Plinn Folder', 'Portfolio', 'Photo']}
27 objects
= ob
.listNearestFolderContents(contentFilter
= filter)
28 objects
= sequence
.sort( objects
, (('title_or_id', 'nocase', 'asc'),) )
33 path
= o
.getPhysicalPath()
36 for name
in path
[1:] :
37 partObject
= getattr(partObject
, name
)
38 sep
= checkView(partObject
) and '/' or '\\'
39 encodedPath
+= sep
+name
41 row
= '<row path="%(path)s" folderish="%(folderish)s" icon="%(icon)s" link="%(link)s">%(title)s</row>' % {
43 'folderish' : o
.isPrincipiaFolderish
,
45 'title' : replaceXMLEntities(o
.title_or_id()),
46 'link' : o
.absolute_url()
51 elif command
== 'info':
52 #linkFunction = (Type == 'Image') and (lambda o : o.absolute_url() + '/index_html') or (lambda o : o.absolute_url())
53 linkFunction
= lambda o
: o
.absolute_url()
55 method_id
= ti
.queryMethodID('info')
56 meth
= method_id
and getattr(ob
, method_id
) or (lambda:'Not implemented')
60 # print info summary in a CDATA section
64 # print the url link in a <link> tag
72 context
.REQUEST
.RESPONSE
.setHeader('content-type', 'text/xml; charset=utf-8')