PNG  IHDR;IDATxܻn0K )(pA 7LeG{ §㻢|ذaÆ 6lذaÆ 6lذaÆ 6lom$^yذag5bÆ 6lذaÆ 6lذa{ 6lذaÆ `}HFkm,mӪôô! x|'ܢ˟;E:9&ᶒ}{v]n&6 h_tڠ͵-ҫZ;Z$.Pkž)!o>}leQfJTu іچ\X=8Rن4`Vwl>nG^is"ms$ui?wbs[m6K4O.4%/bC%t Mז -lG6mrz2s%9s@-k9=)kB5\+͂Zsٲ Rn~GRC wIcIn7jJhۛNCS|j08yiHKֶۛkɈ+;SzL/F*\Ԕ#"5m2[S=gnaPeғL lذaÆ 6l^ḵaÆ 6lذaÆ 6lذa; _ذaÆ 6lذaÆ 6lذaÆ RIENDB` babel.support.LazyProxy
Package babel :: Module support :: Class LazyProxy

Class LazyProxy

object --+
         |
        LazyProxy

Class for proxy objects that delegate to a specified function to evaluate the actual object.

>>> def greeting(name='world'):
...     return 'Hello, %s!' % name
>>> lazy_greeting = LazyProxy(greeting, name='Joe')
>>> print lazy_greeting
Hello, Joe!
>>> u'  ' + lazy_greeting
u'  Hello, Joe!'
>>> u'(%s)' % lazy_greeting
u'(Hello, Joe!)'

This can be used, for example, to implement lazy translation functions that delay the actual translation until the string is actually used. The rationale for such behavior is that the locale of the user may not always be available. In web applications, you only know the locale when processing a request.

The proxy implementation attempts to be as complete as possible, so that the lazy objects should mostly work as expected, for example for sorting:

>>> greetings = [
...     LazyProxy(greeting, 'world'),
...     LazyProxy(greeting, 'Joe'),
...     LazyProxy(greeting, 'universe'),
... ]
>>> greetings.sort()
>>> for greeting in greetings:
...     print greeting
Hello, Joe!
Hello, universe!
Hello, world!
Instance Methods
 
__init__(self, func, *args, **kwargs)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
 
__contains__(self, key)
 
__nonzero__(self)
 
__dir__(self)
 
__iter__(self)
 
__len__(self)
 
__str__(self)
str(x)
 
__unicode__(self)
 
__add__(self, other)
 
__radd__(self, other)
 
__mod__(self, other)
 
__rmod__(self, other)
 
__mul__(self, other)
 
__rmul__(self, other)
 
__call__(self, *args, **kwargs)
 
__lt__(self, other)
 
__le__(self, other)
 
__eq__(self, other)
 
__ne__(self, other)
 
__gt__(self, other)
 
__ge__(self, other)
 
__delattr__(self, name)
x.__delattr__('name') <==> del x.name
 
__getattr__(self, name)
 
__setattr__(self, name, value)
x.__setattr__('name', value) <==> x.name = value
 
__delitem__(self, key)
 
__getitem__(self, key)
 
__setitem__(self, key, value)

Inherited from object: __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __sizeof__, __subclasshook__

Properties
  value

Inherited from object: __class__

Method Details

__init__(self, func, *args, **kwargs)
(Constructor)

 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Overrides: object.__init__
(inherited documentation)

__str__(self)
(Informal representation operator)

 
str(x)
Overrides: object.__str__
(inherited documentation)

__delattr__(self, name)

 
x.__delattr__('name') <==> del x.name
Overrides: object.__delattr__
(inherited documentation)

__setattr__(self, name, value)

 
x.__setattr__('name', value) <==> x.name = value
Overrides: object.__setattr__
(inherited documentation)

Property Details

value

Get Method:
unreachable.value(self)