def index_html(self, instance, REQUEST=None, RESPONSE=None, **kwargs):
    """ make it directly viewable when entering the objects URL """
    blob = self.get(instance, raw=True)  # TODO: why 'raw'?
    charset = instance.getCharset()
    add_download_record(instance)
    return blob.index_html(REQUEST=REQUEST,
                           RESPONSE=RESPONSE,
                           charset=charset,
                           **kwargs)
def index_html(self, instance, REQUEST=None, RESPONSE=None, **kwargs):
    """ make it directly viewable when entering the objects URL """
    blob = self.get(instance, raw=True)    # TODO: why 'raw'?
    charset = instance.getCharset()
    add_download_record(instance)
    return blob.index_html(
        REQUEST=REQUEST, RESPONSE=RESPONSE,
        charset=charset, **kwargs
        )
## Script (Python) "at_download"
##title=Download a file keeping the original uploaded filename
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
from collective.downloadtracker import add_download_record
add_download_record(context)

if traverse_subpath:
    field = context.getWrappedField(traverse_subpath[0])
else:
    field = context.getPrimaryField()
return field.download(context)
Exemple #4
0
 def test_add_download_record(self):
     file = self.portal.file1
     add_download_record(file)
     user, ts = file.getField('download_records').get(file)[0]
     self.assertEqual(user, u'test-user')
     self.assertTrue(isinstance(DateTime.DateTime(ts), DateTime.DateTime))
 def test_add_download_record(self):
     file = self.portal.file1
     add_download_record(file)
     user, ts = file.getField('download_records').get(file)[0]
     self.assertEqual(user, u'test-user')
     self.assertTrue(isinstance(DateTime.DateTime(ts), DateTime.DateTime))