Ńň
ňęJc           @   sE   d  Z  d   Z d   Z d d k l Z d e i f d     YZ d S(   s   Some code helpers.c            s     f d   } | S(   s
  This is used to create an attribute whose value is
    lazily computed. The parameter names an object variable that
    will be used to hold the lazily computed value. At the start,
    this variable should hold the value undefined.

    TODO: Replace this with a nice Python descriptor.

    class Person(object):
        def __init__(self):
            self.name = 'John'
            self.surname = 'Doe'

        @lazy('_fullname')
        def _get_fullname(self):
            return self.name + ' ' + self.surname
    c            s      f d   } | S(   Nc            sH   y t  |    SWn0 t j
 o$   |   } t |   |  | SXd  S(   N(   t   getattrt   AttributeErrort   setattr(   t   selft   result(   t   ft   result_name(    s1   /var/www/Pootle/local_apps/pootle_app/lib/util.pyt	   evaluator+   s    (    (   R   R   (   R   (   R   s1   /var/www/Pootle/local_apps/pootle_app/lib/util.pyt   lazify*   s    (    (   R   R   (    (   R   s1   /var/www/Pootle/local_apps/pootle_app/lib/util.pyt   lazy   s    	c            s+     f d   } t  t    |  d  |  S(   Nc            s   t  |     d  S(   N(   t   delattr(   R   (   t   name(    s1   /var/www/Pootle/local_apps/pootle_app/lib/util.pyt   deleter6   s    (   t   propertyR	   t   None(   R   t   getterR   (    (   R   s1   /var/www/Pootle/local_apps/pootle_app/lib/util.pyt   lazy_property5   s    i˙˙˙˙(   t   modelst   RelatedManagerc           B   s   e  Z d  Z d   Z RS(   sc   Model manager that always does full joins on relations, saves
    us lots of database queries laterc         C   s   t  t |   i   i d d  S(   Nt   depthi   (   t   superR   t   get_query_sett   select_related(   R   (    (    s1   /var/www/Pootle/local_apps/pootle_app/lib/util.pyR   @   s    (   t   __name__t
   __module__t   __doc__R   (    (    (    s1   /var/www/Pootle/local_apps/pootle_app/lib/util.pyR   =   s   N(   R   R	   R   t	   django.dbR   t   ManagerR   (    (    (    s1   /var/www/Pootle/local_apps/pootle_app/lib/util.pyt   <module>   s   		