Edgewall Software

Changes between Initial Version and Version 1 of Ticket #11684, comment 6


Ignore:
Timestamp:
Jul 19, 2014, 9:05:36 AM (10 years ago)
Author:
Jun Omae

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #11684, comment 6

    initial v1  
    99{{{#!diff
    1010diff --git a/trac/cache.py b/trac/cache.py
    11 index 711e2b8..bd6afb6 100644
     11index 711e2b8..fa2ff79 100644
    1212--- a/trac/cache.py
    1313+++ b/trac/cache.py
     
    3030     def make_key(self, cls):
    3131         attr = self.retriever.__name__
    32 @@ -77,6 +79,9 @@ class CachedSingletonProperty(CachedPropertyBase):
    33              id = self.id = key_to_id(self.make_key(instance.__class__))
    34          CacheManager(instance.env).invalidate(id)
     32@@ -49,6 +51,9 @@ class CachedPropertyBase(object):
     33                 break
     34         return '%s.%s.%s' % (cls.__module__, cls.__name__, attr)
    3535
    3636+    def __set__(self, instance, value):
     
    3838+
    3939
    40  class CachedProperty(CachedPropertyBase):
    41      """Cached property descriptor for classes having potentially
    42 @@ -111,6 +116,9 @@ class CachedProperty(CachedPropertyBase):
    43              setattr(instance, self.key_attr, id)
    44          CacheManager(instance.env).invalidate(id)
     40 class CachedSingletonProperty(CachedPropertyBase):
     41     """Cached property descriptor for classes behaving as singletons
     42}}}
    4543
    46 +    def __set__(self, instance, value):
    47 +        raise AttributeError('Setting attribute is not allowed.')
    48 +
    49 
    50  def cached(fn_or_attr=None):
    51      """Method decorator creating a cached attribute from a data
    52 diff --git a/trac/util/__init__.py b/trac/util/__init__.py
    53 index c0b81c2..1612a85 100644
    54 --- a/trac/util/__init__.py
    55 +++ b/trac/util/__init__.py
    56 @@ -1114,6 +1114,9 @@ class lazy(object):
    57          setattr(instance, self.fn.__name__, result)
    58          return result
    59 
    60 +    def __set__(self, instance, value):
    61 +        raise AttributeError('Setting attribute is not allowed.')
    62 +
    63 
    64  # -- algorithmic utilities
    65 
    66 }}}
     44Edit: removed `__set__` from `lazy` class in the patch. Cannot create `TicketSystem` instance with `__set__`.