~divmod-dev/divmod.org/in-memory-quotient-tests-2403

« back to all changes in this revision

Viewing changes to Axiom/axiom/substore.py

  • Committer: washort
  • Date: 2007-11-15 19:58:09 UTC
  • Revision ID: svn-v4:866e43f7-fbfc-0310-8f2a-ec88d1da2979:trunk:14265
merge in-memory-substores-1853.
Author: washort
Reviewer: exarkun

Allow in-memory stores to have in-memory substores, as well as on-disk files.
Closes #1853, #2203.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
        """
27
27
        Create a new SubStore, allocating a new file space for it.
28
28
        """
29
 
        storepath = store.newDirectory(*pathSegments)
30
 
        self = cls(store=store, storepath=storepath)
 
29
        if store.dbdir is None:
 
30
            self = cls(store=store, storepath=None)
 
31
        else:
 
32
            storepath = store.newDirectory(*pathSegments)
 
33
            self = cls(store=store, storepath=storepath)
31
34
        self.open()
32
35
        self.close()
33
36
        return self
43
46
        if hasattr(self, 'substore'):
44
47
            return self.substore
45
48
        else:
46
 
            s = self.substore = Store(self.storepath.path,
47
 
                                      parent=self.store,
48
 
                                      idInParent=self.storeID,
49
 
                                      debug=debug)
 
49
            s = self.substore = self.createStore(debug)
50
50
            s._openSubStore = self # don't fall out of cache as long as the
51
51
                                   # store is alive!
52
52
            return s
53
53
 
 
54
    def createStore(self, debug):
 
55
        """
 
56
        Create the actual Store this Substore represents.
 
57
        """
 
58
        if self.storepath is None:
 
59
            self.store._memorySubstores.append(self) # don't fall out of cache
 
60
            if self.store.filesdir is None:
 
61
                filesdir = None
 
62
            else:
 
63
                filesdir = (self.store.filesdir.child("_substore_files")
 
64
                                               .child(str(self.storeID))
 
65
                                               .path)
 
66
            return Store(parent=self.store,
 
67
                         filesdir=filesdir,
 
68
                         idInParent=self.storeID,
 
69
                         debug=debug)
 
70
        else:
 
71
            return Store(self.storepath.path,
 
72
                         parent=self.store,
 
73
                         idInParent=self.storeID,
 
74
                         debug=debug)
 
75
 
54
76
    def __conform__(self, interface):
55
77
        """
56
78
        I adapt my store object to whatever interface I am adapted to.  This
72
94
        return interface(self)
73
95
 
74
96
 
75
 
 
76
97
class SubStoreStartupService(Item, service.Service):
77
98
    """
78
99
    This class no longer exists.  It is here simply to trigger an upgrade which