This file is indexed.

/usr/share/pyshared/myghty/ext/memcached.py is in python-myghty 1.1-5.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import memcache
from myghty.synchronization import *
from myghty.container import NamespaceManager, Container

import sys

class MemcachedNamespaceManager(NamespaceManager):

    def __init__(self, context, namespace, url, **params):
        NamespaceManager.__init__(self, context, namespace, **params)
        self.mc = memcache.Client([url], debug=0)

    # memcached does its own locking.  override our own stuff
    def do_acquire_read_lock(self): pass
    def do_release_read_lock(self): pass
    def do_acquire_write_lock(self, wait = True): return True
    def do_release_write_lock(self): pass

    # override open/close to do nothing, keep memcache connection open as long
    # as possible
    def open(self, *args, **params):pass
    def close(self, *args, **params):pass

    def __getitem__(self, key):
        value = self.mc.get(self.namespace + "_" + key)
        if value is None:
            raise KeyError(key)
        return value

    def __contains__(self, key):
        return self.mc.get(self.namespace + "_" + key) is not None

    def has_key(self, key):
        return self.mc.get(self.namespace + "_" + key) is not None

    def __setitem__(self, key, value):
        keys = self.mc.get(self.namespace + ':keys')
        if keys is None:
            keys = {}
        keys[key] = True
        self.mc.set(self.namespace + ':keys', keys)
        self.mc.set(self.namespace + "_" + key, value)

    def __delitem__(self, key):
        keys = self.mc.get(self.namespace + ':keys')
        try:
            del keys[key]
            self.mc.delete(self.namespace + "_" + key)
            self.mc.set(self.namespace + ':keys', keys)
        except KeyError:
            raise

    def do_remove(self):
        pass

    def keys(self):
        keys = self.mc.get(self.namespace + ':keys')
        if keys is None:
            return []
        else:
            return keys.keys()

class MemcachedContainer(Container):

    def do_init(self, **params):
        self.funclock = None

    def do_create_namespace_manager(self, context, namespace, url, **params):
        return MemcachedNamespaceManager(context, namespace, url, **params)

    def lock_createfunc(self, wait = True):
        if self.funclock is None:
            self.funclock = Synchronizer(identifier =
"memcachedcontainer/funclock/%s" % self.namespacemanager.namespace,
use_files = True, lock_dir = self.namespacemanager.lock_dir)

        return self.funclock.acquire_write_lock(wait)

    def unlock_createfunc(self):
        self.funclock.release_write_lock()