provide URL for direct download for documents (files)
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@2958 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
a37c582dea
commit
1cd31af11b
2 changed files with 14 additions and 2 deletions
|
@ -29,7 +29,8 @@ from zope import component
|
|||
from zope.cachedescriptors.property import Lazy
|
||||
from zope.traversing.browser import absoluteURL
|
||||
|
||||
from cybertools.integrator.bscw import ContainerFactory
|
||||
from cybertools.integrator.base import mimeTypes
|
||||
from cybertools.integrator.bscw import ContainerFactory, File
|
||||
from cybertools.integrator.interfaces import IContainerFactory
|
||||
from cybertools.integrator.interfaces import IItemFactory, IFileFactory
|
||||
|
||||
|
@ -70,11 +71,23 @@ class ItemView(BaseView):
|
|||
super(ItemView, self).__init__(context, request)
|
||||
self.parentView = parentView
|
||||
|
||||
@Lazy
|
||||
def baseName(self):
|
||||
return self.context.icon
|
||||
|
||||
@Lazy
|
||||
def url(self):
|
||||
if isinstance(self.context, File):
|
||||
return self.downloadUrl
|
||||
url = self.parentView.url
|
||||
return '%s?id=%s' % (url, self.context.internalPath)
|
||||
|
||||
@Lazy
|
||||
def downloadUrl(self):
|
||||
urlInfo = self.context.externalURLInfo
|
||||
extension = (mimeTypes.get(self.context.contentType) or ['bin'])[0]
|
||||
return '%s/d%s/%s.%s' % (urlInfo.baseUrl, urlInfo.path, self.title, extension)
|
||||
|
||||
@property
|
||||
def breadCrumbs(self):
|
||||
parents = list(self.context.parents)
|
||||
|
|
|
@ -206,7 +206,6 @@ class ReadContainer(BSCWProxyBase, ReadContainer):
|
|||
return sorted((self.get(k) for k in self),
|
||||
key=lambda x: (x.itemType != 'Folder', x.title.lower()))
|
||||
|
||||
|
||||
def __len__(self):
|
||||
return len(self.keys())
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue