Coverage for lino/utils/media.py : 54%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# -*- coding: UTF-8 -*- # Copyright 2013-2015 Luc Saffre # License: BSD (see file COPYING for details) """
"""Represents a file on the server below :setting:`MEDIA_ROOT` with two properties :attr:`name` and :attr:`url`.
It also takes into consideration the settings :attr:`use_davlink <lino.core.site.Site.use_davlink>` :attr:`webdav_root <lino.core.site.Site.webdav_root>` and :attr:`webdav_url <lino.core.site.Site.webdav_url>`
"""
self.editable = editable self.parts = parts
def name(self): "return the filename on the server" if self.editable and has_davlink: return os.path.join(settings.SITE.webdav_root, *self.parts) return os.path.join(settings.MEDIA_ROOT, *self.parts)
def url(self): "return the url that points to file on the server" if self.editable and has_davlink: return settings.SITE.webdav_url + "/".join(self.parts) return settings.SITE.build_media_url(*self.parts)
ip = ar.request.META.get('REMOTE_ADDR', 'unknown_ip') super(TmpMediaFile, self).__init__( False, 'cache', 'appy' + fmt, ip, str(ar.actor) + '.' + fmt)
import doctest doctest.testmod()
_test() |