Contact: fumanchu@aminus.org

Log in as guest/dejavu to create tickets

I think I've seen this ORM somewhere before...

root/trunk/dejavu/storage/storesqlite.py

Revision 453 (checked in by fumanchu, 6 years ago)

MAJOR REFACTOR: moved Arena from assumed root of storage graph to arbitrary node. Still lots of dark corners to finish migrating, but the core works. This now means users can bind Sandboxes to any store, and can mediate multiple stores at any point in the SM graph.

  • Property svn:eol-style set to native
Line 
1 import os
2
3 from geniusql.providers import sqlite
4 from dejavu.storage import db
5
6
7 class StorageManagerSQLite(db.StorageManagerDB):
8     """StoreManager to save and retrieve Units via _sqlite."""
9    
10     databaseclass = sqlite.SQLiteDatabase
11    
12     def __init__(self, allOptions={}):
13         allOptions = allOptions.copy()
14         allOptions['name'] = allOptions.pop('Database', '')
15        
16         pd = str(allOptions.get('Perfect Dates', 'False')).lower()
17         allOptions['using_perfect_dates'] = (pd == "true")
18        
19         db.StorageManagerDB.__init__(self, allOptions)
20    
21     def reserve(self, unit):
22         """Reserve a persistent slot for unit."""
23         self.reserve_lock.acquire()
24         try:
25             # First, see if our db subclass has a handler that
26             # uses the DB to generate the appropriate identifier(s).
27             seqclass = unit.sequencer.__class__.__name__
28             if (seqclass == "UnitSequencerInteger"
29                     and sqlite._autoincrement_support):
30                 self._seq_UnitSequencerInteger(unit)
31             else:
32                 self._manual_reserve(unit)
33             unit.cleanse()
34         finally:
35             self.reserve_lock.release()
36    
37     #                               Schemas                               #
38    
39     def _make_column(self, cls, key):
40         col = db.StorageManagerDB._make_column(self, cls, key)
41         if col.autoincrement and not sqlite._autoincrement_support:
42             col.autoincrement = False
43             col.initial = 0
44         return col
45
Note: See TracBrowser for help on using the browser.