additional attribute 'localFilename' for IFile
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@1788 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
271b0da1c2
commit
a0838de6f1
4 changed files with 11 additions and 2 deletions
|
@ -294,6 +294,7 @@ class EditObject(FormController):
|
|||
ct = contentType[0]
|
||||
self.request.form['form.contentType'] = ct
|
||||
adapted.contentType = ct
|
||||
adapted.localFilename = filename
|
||||
setattr(adapted, fn, value)
|
||||
if self.old or self.selected:
|
||||
self.assignConcepts(obj)
|
||||
|
|
|
@ -22,10 +22,12 @@ View class for resource objects.
|
|||
$Id$
|
||||
"""
|
||||
|
||||
import urllib
|
||||
from zope.cachedescriptors.property import Lazy
|
||||
from zope import component
|
||||
from zope.app import zapi
|
||||
from zope.app.catalog.interfaces import ICatalog
|
||||
from zope.app.container.interfaces import INameChooser
|
||||
from zope.dublincore.interfaces import ICMFDublinCore
|
||||
from zope.app.form.browser.textwidgets import FileWidget
|
||||
from zope.app.pagetemplate import ViewPageTemplateFile
|
||||
|
@ -36,12 +38,14 @@ from zope.proxy import removeAllProxies
|
|||
from zope.schema.interfaces import IBytes
|
||||
from zope.security import canAccess, canWrite
|
||||
from zope.security.proxy import removeSecurityProxy
|
||||
from zope.traversing.api import getName, getParent
|
||||
|
||||
from cybertools.typology.interfaces import IType
|
||||
from loops.browser.common import EditForm, BaseView, Action
|
||||
from loops.browser.concept import ConceptRelationView, ConceptConfigureView
|
||||
from loops.browser.node import NodeView, node_macros
|
||||
from loops.browser.util import html_quote
|
||||
from loops.common import adapted
|
||||
from loops.interfaces import IBaseResource, IDocument, IMediaAsset, ITextDocument
|
||||
from loops.interfaces import ITypeConcept
|
||||
from loops.versioning.browser import version_macros
|
||||
|
@ -159,8 +163,11 @@ class ResourceView(BaseView):
|
|||
ct = context.contentType
|
||||
#if useAttachment or (not ct.startswith('image/') and ct != 'application/pdf'):
|
||||
if useAttachment:
|
||||
filename = adapted(self.context).localFilename or getName(self.context)
|
||||
#filename = urllib.quote(filename)
|
||||
filename = INameChooser(getParent(self.context)).normalizeName(filename)
|
||||
response.setHeader('Content-Disposition',
|
||||
'attachment; filename=%s' % zapi.getName(self.context))
|
||||
'attachment; filename=%s' % filename)
|
||||
return data
|
||||
|
||||
def download(self):
|
||||
|
|
|
@ -614,6 +614,7 @@ class IFile(IResourceAdapter, IResourceSchema):
|
|||
default='',
|
||||
missing_value='',
|
||||
required=False)
|
||||
localFilename = Attribute('Filename provided during upload.')
|
||||
|
||||
|
||||
class IExternalFile(IFile):
|
||||
|
|
|
@ -27,7 +27,7 @@ from zope.app import zapi
|
|||
from zope.app.container.btree import BTreeContainer
|
||||
from zope.app.container.contained import Contained
|
||||
from zope.app.file.image import Image
|
||||
from zope.app.file.interfaces import IFile
|
||||
#from zope.app.file.interfaces import IFile
|
||||
from zope.filerepresentation.interfaces import IReadFile, IWriteFile
|
||||
from zope.cachedescriptors.property import Lazy
|
||||
from zope.component import adapts
|
||||
|
|
Loading…
Add table
Reference in a new issue