There are no implemented interfaces.
There are no attributes in this class.
show()
Sets various headers if the request is present and returns the data of the file. If the "If-Modified-Since" header is set and the context implements IZopeDublinCore, data is only returned if the modification date of the context is new than the date in the "If-Modified-Since" header >>> from zope.publisher.browser import BrowserView, TestRequest >>> class FileTestView(FileView, BrowserView): pass >>> import pytz >>> class MyFile(object): ... contentType='text/plain' ... data="data of file" ... modified = datetime(2006,1,1,tzinfo=pytz.utc) ... def getSize(self): ... return len(self.data)
>>> aFile = MyFile() >>> request = TestRequest() >>> view = FileTestView(aFile,request) >>> view.show() 'data of file' >>> request.response.getHeader('Content-Type') 'text/plain' >>> request.response.getHeader('Content-Length') '12'
If the file is adaptable to IZopeDublinCore the "Last-Modified" header is also set.
>>> request.response.getHeader('Last-Modified') is None True
For the test we just declare that our file provides IZopeDublinCore >>> from zope.interface import directlyProvides >>> directlyProvides(aFile,IZopeDublinCore) >>> request = TestRequest() >>> view = FileTestView(aFile,request) >>> view.show() 'data of file' >>> request.response.getHeader('Last-Modified') 'Sun, 01 Jan 2006 00:00:00 GMT'
If the "If-Modified-Since" header is set and is newer a 304 status is returned and the value is empty.
>>> modified = datetime(2007,12,31,tzinfo=pytz.utc) >>> modHeader = zope.datetime.rfc1123_date(zope.datetime.time(modified.isoformat())) >>> request = TestRequest(IF_MODIFIED_SINCE=modHeader)
>>> view = FileTestView(aFile,request) >>> view.show() '' >>> request.response.getStatus() 304
tag(height=None, width=None, alt=None, scale=0, xscale=0, yscale=0, css_class=None, **args)
Generate an HTML IMG tag for this image, with customization. Arguments to self.tag() can be any valid attributes of an IMG tag. src will always be an absolute pathname, to prevent redundant downloading of images. Defaults are applied intelligently for height, width, and alt. If specified, the scale, xscale, and yscale keyword arguments will be used to automatically adjust the output height and width values of the image tag.
Since 'class' is a Python reserved word, it cannot be passed in directly in keyword arguments which is a problem if you are trying to use tag() to include a CSS class. The tag() method will accept a css_class argument that will be converted to class in the output tag to work around this.