Exemplo n.º 1
0
 def createVersions(self, path):
     print "generating versions for: ", path
     from filebrowser_safe.settings import VERSIONS
     from filebrowser_safe.functions import version_generator
     for version in VERSIONS:
         #print "                          ", version
         version_generator(path, version, True)
Exemplo n.º 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)
         context[self.var_name] = FileObject(version_path)
     except:
         context[self.var_name] = ""
     return ''
Exemplo n.º 3
0
 def createVersions(self, path):
     print "generating versions for: ", path
     from filebrowser_safe.settings import VERSIONS
     from filebrowser_safe.functions import version_generator
     for version in VERSIONS:
         #print "                          ", version
         version_generator(path, version, True)
Exemplo n.º 4
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 ""