~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/decorators.py

  • Committer: John Arbash Meinel
  • Date: 2006-03-08 14:31:23 UTC
  • mfrom: (1598 +trunk)
  • mto: (1685.1.1 bzr-encoding)
  • mto: This revision was merged to the branch mainline in revision 1752.
  • Revision ID: john@arbash-meinel.com-20060308143123-448308b0db4de410
[merge] bzr.dev 1573, lots of updates

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
        def branch_method(self, ...):
33
33
            stuff
34
34
    """
35
 
    def decorated(self, *args, **kwargs):
 
35
    def read_locked(self, *args, **kwargs):
36
36
        self.lock_read()
37
37
        try:
38
38
            return unbound(self, *args, **kwargs)
39
39
        finally:
40
40
            self.unlock()
41
 
    decorated.__doc__ = unbound.__doc__
42
 
    decorated.__name__ = unbound.__name__
43
 
    return decorated
 
41
    read_locked.__doc__ = unbound.__doc__
 
42
    read_locked.__name__ = unbound.__name__
 
43
    return read_locked
44
44
 
45
45
 
46
46
def needs_write_lock(unbound):
47
47
    """Decorate unbound to take out and release a write lock."""
48
 
    def decorated(self, *args, **kwargs):
 
48
    def write_locked(self, *args, **kwargs):
49
49
        self.lock_write()
50
50
        try:
51
51
            return unbound(self, *args, **kwargs)
52
52
        finally:
53
53
            self.unlock()
54
 
    decorated.__doc__ = unbound.__doc__
55
 
    decorated.__name__ = unbound.__name__
56
 
    return decorated
 
54
    write_locked.__doc__ = unbound.__doc__
 
55
    write_locked.__name__ = unbound.__name__
 
56
    return write_locked
57
57