341babb0a2098dd5d11616d722f49d0683376ee4
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 if not method_id
or not hasattr(ob
, method_id
) :
57 meth
= lambda:'Not implemented'
59 path
= list(ob
.getPhysicalPath())
60 path
.append(method_id
)
61 app
= context
.restrictedTraverse('/')
62 meth
= app
.restrictedTraverse(tuple(path
))
67 # print info summary in a CDATA section
71 # print the url link in a <link> tag
79 context
.REQUEST
.RESPONSE
.setHeader('content-type', 'text/xml; charset=utf-8')