def createVersions(self, path):
     print "generating versions for: ", path
     from bp.contrib.filebrowser.settings import VERSIONS
     from bp.contrib.filebrowser.functions import version_generator
     for version in VERSIONS:
         #print "                          ", version
         version_generator(path, version, True)
Beispiel #2
0
 def render(self, context):
     try:
         source = self.src.resolve(context)
     except VariableDoesNotExist:
         return None
     if self.version_prefix:
         version_prefix = self.version_prefix
     else:
         try:
             version_prefix = self.version_prefix_var.resolve(context)
         except VariableDoesNotExist:
             return None
     try:
         version_path = get_version_path(url_to_path(str(source)), version_prefix)
         if not os.path.isfile(os.path.join(MEDIA_ROOT, version_path)):
             # create version
             version_path = version_generator(url_to_path(str(source)), version_prefix)
         elif os.path.getmtime(os.path.join(MEDIA_ROOT, url_to_path(str(source)))) > os.path.getmtime(os.path.join(MEDIA_ROOT, version_path)):
             # recreate version if original image was updated
             version_path = version_generator(url_to_path(str(source)), version_prefix, force=True)
         return path_to_url(version_path)
     except:
         return ""