Contact: fumanchu@aminus.org

Log in as guest/dejavu to create tickets

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

Changeset 604

Show
Ignore:
Timestamp:
06/02/09 11:49:28
Author:
fumanchu
Message:

New UnitSequencerDynamic?, for identifier schemes the MUST be generated by the backend.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/dejavu/storage/db.py

    r600 r604  
    162162            self.log(logflags.RESERVE.message(unit)) 
    163163     
    164     def _seq_UnitSequencerInteger(self, unit): 
     164    def _seq_UnitSequencerDynamic(self, unit): 
    165165        """Reserve a unit (using the table's autoincrement fields).""" 
    166166        cls = unit.__class__ 
     
    170170        for k, v in newids.iteritems(): 
    171171            setattr(unit, k, v) 
     172    _seq_UnitSequencerInteger = _seq_UnitSequencerDynamic 
    172173     
    173174    def _manual_reserve(self, unit): 
  • trunk/dejavu/storage/multischema.py

    r561 r604  
    5555        self.db.log = logger 
    5656     
    57     def _seq_UnitSequencerInteger(self, unit): 
     57    def _seq_UnitSequencerDynamic(self, unit): 
    5858        """Reserve a unit (using the table's autoincrement fields).""" 
    5959        # Grab the new ID. This is threadsafe because reserve has a mutex. 
     
    6161        for k, v in newids.iteritems(): 
    6262            setattr(unit, k, v) 
     63    _seq_UnitSequencerInteger = _seq_UnitSequencerDynamic 
    6364     
    6465    def _manual_reserve(self, unit): 
  • trunk/dejavu/storage/storesqlite.py

    r453 r604  
    2626            # uses the DB to generate the appropriate identifier(s). 
    2727            seqclass = unit.sequencer.__class__.__name__ 
    28             if (seqclass == "UnitSequencerInteger" 
    29                     and sqlite._autoincrement_support): 
    30                 self._seq_UnitSequencerInteger(unit) 
     28            seq_handler = getattr(self, "_seq_%s" % seqclass, None) 
     29            if (seq_handler and 
     30                   (seqclass != "UnitSequencerInteger" or 
     31                    sqlite._autoincrement_support)): 
     32                seq_handler(unit) 
    3133            else: 
    3234                self._manual_reserve(unit) 
  • trunk/dejavu/units.py

    r598 r604  
    327327            newvalue = maxid 
    328328        setattr(unit, unit.identifiers[0], newvalue) 
     329 
     330 
     331class UnitSequencerDynamic(UnitSequencer): 
     332    """A sequencer for Unit identifiers which MUST be generated by storage.""" 
     333    pass 
    329334 
    330335