OLD | NEW |
1 # Copyright: 2011 MoinMoin:RonnyPfannschmidt | 1 # Copyright: 2011 MoinMoin:RonnyPfannschmidt |
2 # Copyright: 2011 MoinMoin:ThomasWaldmann | 2 # Copyright: 2011 MoinMoin:ThomasWaldmann |
3 # License: GNU GPL v2 (or any later version), see LICENSE.txt for details. | 3 # License: GNU GPL v2 (or any later version), see LICENSE.txt for details. |
4 | 4 |
5 """ | 5 """ |
6 MoinMoin - backend that ties together 4 key/value stores | 6 MoinMoin - backend that ties together 4 key/value stores |
7 | 7 |
8 A meta store (a ByteStore): | 8 A meta store (a ByteStore): |
9 | 9 |
10 - key = revid UUID (bytes, ascii) | 10 - key = revid UUID (bytes, ascii) |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 | 135 |
136 def retrieve(self, metaid): | 136 def retrieve(self, metaid): |
137 meta = self._get_meta(metaid) | 137 meta = self._get_meta(metaid) |
138 dataid = meta[DATAID] | 138 dataid = meta[DATAID] |
139 data = self._get_data(dataid) | 139 data = self._get_data(dataid) |
140 return meta, data | 140 return meta, data |
141 | 141 |
142 def retrieve_branch(self, branchid): | 142 def retrieve_branch(self, branchid): |
143 return self._get_branch(branchid) | 143 return self._get_branch(branchid) |
144 ···· | 144 ···· |
145 def retrieve_branch(self, userheadid): | 145 def retrieve_userhead(self, userheadid): |
146 return self._get_userhead(userheadid) | 146 return self._get_userhead(userheadid) |
147 | 147 |
148 | 148 |
149 class MutableBackend(Backend, MutableBackendBase): | 149 class MutableBackend(Backend, MutableBackendBase): |
150 """ | 150 """ |
151 same as Backend, but read/write | 151 same as Backend, but read/write |
152 """ | 152 """ |
153 def create(self): | 153 def create(self): |
154 self.meta_store.create() | 154 self.meta_store.create() |
155 self.data_store.create() | 155 self.data_store.create() |
(...skipping 24 matching lines...) Expand all Loading... |
180 return metaid | 180 return metaid |
181 | 181 |
182 def store_branch(self, branch): | 182 def store_branch(self, branch): |
183 branchid = branch.get(BRANCH_ID, make_uuid()) | 183 branchid = branch.get(BRANCH_ID, make_uuid()) |
184 branch = self._serialize(branch) | 184 branch = self._serialize(branch) |
185 self.branches_store[branchid] = branch | 185 self.branches_store[branchid] = branch |
186 return branchid | 186 return branchid |
187 | 187 |
188 def store_userhead(self, userhead): | 188 def store_userhead(self, userhead): |
189 uhid = userhead.get(UH_ID, make_uuid()) | 189 uhid = userhead.get(UH_ID, make_uuid()) |
190 userhead = self._serialize(branch) | 190 userhead = self._serialize(userhead) |
191 self.userheads_store[userheadid] = userhead | 191 self.userheads_store[uhid] = userhead |
192 return userheadid | 192 return uhid |
193 | 193 |
194 def store(self, meta, data): | 194 def store(self, meta, data): |
195 # XXX Idea: we could check the type the store wants from us: | 195 # XXX Idea: we could check the type the store wants from us: |
196 # if it is a str/bytes (BytesStore), just use meta "as is", | 196 # if it is a str/bytes (BytesStore), just use meta "as is", |
197 # if it is a file (FileStore), wrap it into StringIO and give that to th
e store. | 197 # if it is a file (FileStore), wrap it into StringIO and give that to th
e store. |
198 if DATAID not in meta: | 198 if DATAID not in meta: |
199 tfw = TrackingFileWrapper(data, hash_method=HASH_ALGORITHM) | 199 tfw = TrackingFileWrapper(data, hash_method=HASH_ALGORITHM) |
200 dataid = make_uuid() | 200 dataid = make_uuid() |
201 self.data_store[dataid] = tfw | 201 self.data_store[dataid] = tfw |
202 meta[DATAID] = dataid | 202 meta[DATAID] = dataid |
(...skipping 25 matching lines...) Expand all Loading... |
228 | 228 |
229 def _del_data(self, dataid): | 229 def _del_data(self, dataid): |
230 del self.data_store[dataid] | 230 del self.data_store[dataid] |
231 | 231 |
232 def remove(self, metaid): | 232 def remove(self, metaid): |
233 meta = self._get_meta(metaid) | 233 meta = self._get_meta(metaid) |
234 dataid = meta[DATAID] | 234 dataid = meta[DATAID] |
235 self._del_meta(metaid) | 235 self._del_meta(metaid) |
236 self._del_data(dataid) | 236 self._del_data(dataid) |
237 | 237 |
OLD | NEW |