provide raw rendering of target object via render.html
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@3244 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
c80096244c
commit
cb975d38c7
4 changed files with 19 additions and 17 deletions
|
@ -644,21 +644,16 @@
|
|||
|
||||
<!-- render file or image assigned to a node as target -->
|
||||
|
||||
<page
|
||||
name="view"
|
||||
for="loops.interfaces.INode"
|
||||
class=".node.NodeView"
|
||||
attribute="targetDefaultView"
|
||||
permission="zope.View"
|
||||
/>
|
||||
|
||||
<page
|
||||
name="download.html"
|
||||
for="loops.interfaces.INode"
|
||||
class=".node.NodeView"
|
||||
attribute="targetDownload"
|
||||
permission="zope.View"
|
||||
/>
|
||||
<pages for="loops.interfaces.INode"
|
||||
class=".node.NodeView"
|
||||
permission="zope.View">
|
||||
<page name="view"
|
||||
attribute="targetDefaultView" />
|
||||
<page name="download.html"
|
||||
attribute="targetDownload" />
|
||||
<page name="render.html"
|
||||
attribute="targetRender" />
|
||||
</pages>
|
||||
|
||||
<!-- vocabulary, traversing, and other stuff -->
|
||||
|
||||
|
|
|
@ -364,6 +364,9 @@ class NodeView(BaseView):
|
|||
def targetDownload(self):
|
||||
return self.targetView('download.html', 'download')
|
||||
|
||||
def targetRender(self):
|
||||
return self.targetView('download.html', 'show')
|
||||
|
||||
@Lazy
|
||||
def virtualTarget(self):
|
||||
obj = self.virtualTargetObject
|
||||
|
|
|
@ -165,8 +165,6 @@ class ResourceView(BaseView):
|
|||
context = ti(context)
|
||||
data = context.data
|
||||
response = self.request.response
|
||||
response.setHeader('Content-Type', context.contentType)
|
||||
response.setHeader('Content-Length', len(data))
|
||||
ct = context.contentType
|
||||
#if useAttachment or (not ct.startswith('image/') and ct != 'application/pdf'):
|
||||
if useAttachment:
|
||||
|
@ -175,6 +173,11 @@ class ResourceView(BaseView):
|
|||
filename = NameChooser(getParent(self.context)).normalizeName(filename)
|
||||
response.setHeader('Content-Disposition',
|
||||
'attachment; filename=%s' % filename)
|
||||
response.setHeader('Content-Length', len(data))
|
||||
if ct.startswith('text/'):
|
||||
response.setHeader('Content-Type', 'text/html')
|
||||
return self.renderText(data, ct)
|
||||
response.setHeader('Content-Type', ct)
|
||||
return data
|
||||
|
||||
def download(self):
|
||||
|
|
|
@ -165,6 +165,7 @@ class ResourceAdapterBase(AdapterBase):
|
|||
|
||||
storageName = None
|
||||
storageParams = None
|
||||
localFilename = None
|
||||
|
||||
def getChildren(self):
|
||||
return []
|
||||
|
|
Loading…
Add table
Reference in a new issue