コード例 #1
0
 def render(self, context):
     try:
         formatname = self.format.resolve(context)
         image = self.image.resolve(context)
     except template.VariableDoesNotExist:
         return ''
     try:
         format_cls = formats.get(formatname)
     except formats.FormatDoesNotExist:
         return ''
     try:
         imagequery = get_imagequery(image)
     except IOError: # handle missing files
         return ''
     format = format_cls(imagequery)
     if self.allow_lazy and not self.name and not format._execute()._exists():
         from imagequery.models import LazyFormat
         lazy_format = LazyFormat(format=formatname)
         lazy_format.query = imagequery
         lazy_format.save()
         return lazy_format.get_absolute_url()
     if self.name:
         context[self.name] = format
         return ''
     else:
         try:
             return format.url()
         except:
             return ''
コード例 #2
0
    def render(self, context):
        try:
            formatname = self.format.resolve(context)
            image = self.image.resolve(context)
        except template.VariableDoesNotExist:
            return ''
        try:
            format_cls = formats.get(formatname)
        except formats.FormatDoesNotExist:
            return ''
        try:
            imagequery = get_imagequery(image)
        except IOError:  # handle missing files
            return ''
        format = format_cls(imagequery)
        if self.allow_lazy and not self.name and not format._execute()._exists(
        ):
            from imagequery.models import LazyFormat

            lazy_format = LazyFormat(format=formatname)
            lazy_format.query = imagequery
            lazy_format.save()
            return lazy_format.get_absolute_url()
        if self.name:
            context[self.name] = format
            return ''
        else:
            try:
                return format.url()
            except:
                return ''
コード例 #3
0
        def generate_image_url(self):
            from imagequery import formats

            format = formats.get(self.format)
            return format(self.query).url()
コード例 #4
0
ファイル: models.py プロジェクト: team23/django_imagequery
        def generate_image_url(self):
            from imagequery import formats

            format = formats.get(self.format)
            return format(self.query).url()