google-code-export / django-photologue

Automatically exported from code.google.com/p/django-photologue
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Suggestion: stop using get_SIZE_url as the method names #91

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
This caused a HUGE confusion in #django recently (and I could see it
happening elsewhere), as everyone logically assumed the user's issue was in
trying to use the old, outdated, get_imagefield_url method on an object,
when instead it was your magic hacking for get_SIZE_url, using the same
format as the now non-existent methods in django

Original issue reported on code.google.com by cgr...@gmail.com on 16 Dec 2008 at 9:44

GoogleCodeExporter commented 9 years ago
This is already on my list for version 3 and I'll mark it as such. Thanks.

Original comment by justin.d...@gmail.com on 16 Dec 2008 at 1:21

GoogleCodeExporter commented 9 years ago

Original comment by justin.d...@gmail.com on 16 Dec 2008 at 1:21

GoogleCodeExporter commented 9 years ago
as a temporary workaround, I did something like this:

class Picture(photologue.models.ImageModel) :
    def __init__(self, *args, **kwargs):
        self.sized_image=ImageSizeAccessor()
        self.sized_image._parent = self
        super(Picture, self).__init__(*args, **kwargs)

class ImageSizeAccessor(object):
    """
    convenient argument-free image size access for templates through the
    sized_image attribute
    """
    def __getitem__(self, key):
        return {
          'size': getattr(self._parent, 'get_%s_size' % key)(),
          'url': getattr(self._parent, 'get_%s_url' % key)(),
          'filename': getattr(self._parent, 'get_%s_filename' % key)(),
          # 'photosize': getattr(self.å_parent, 'get_%s_photosize' % key),
        }

HTH

Original comment by dan.mack...@gmail.com on 24 Dec 2008 at 8:25