Contact: fumanchu@aminus.org

Log in as guest/dejavu to create tickets

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

Changeset 364

Show
Ignore:
Timestamp:
12/25/06 16:33:22
Author:
fumanchu
Message:

Changed UnitSequencerNull? to UnitSequencer?, and made the other UnitSequencers? inherit from it just for fun.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/doc/modeling.html

    r363 r364  
    343343UnitSequencerInteger in this way.]</p> 
    344344 
    345 <p>The other useful Sequencer is <tt>UnitSequencerNull</tt>, which simply 
    346 raises an error when asked to generate an ID. If you set <tt>ClassA.ID</tt> 
    347 to a string or unicode type, you'll probably want to set 
    348 <tt>ClassA.sequencer = dejavu.UnitSequencerNull()</tt>, and form ID values 
     345<p>The other useful Sequencer is the base class <tt>UnitSequencer</tt>, 
     346which simply raises an error when asked to generate an ID. If you set 
     347<tt>ClassA.ID</tt> to a string or unicode type, you'll probably want to set 
     348<tt>ClassA.sequencer = dejavu.UnitSequencer()</tt>, and form ID values 
    349349in your own code.</p> 
    350350 
  • trunk/schemas.py

    r363 r364  
    1111    ID = units.UnitProperty(unicode) 
    1212    Version = units.UnitProperty(int) 
    13     sequencer = units.UnitSequencerNull() 
     13    sequencer = units.UnitSequencer() 
    1414 
    1515 
  • trunk/storage/db.py

    r363 r364  
    658658         
    659659        class AutoUnitClass(dejavu.Unit): 
    660             sequencer = dejavu.UnitSequencerNull() 
     660            sequencer = dejavu.UnitSequencer() 
    661661            identifiers = tuple([k for k in table.columns 
    662662                                 if table.columns[k].key]) 
     
    740740                code.append(sequencer) 
    741741        else: 
    742             code.append("    sequencer = UnitSequencerNull()") 
     742            code.append("    sequencer = UnitSequencer()") 
    743743         
    744744        if len(code) == 1: 
  • trunk/test/zoo_fixture.py

    r363 r364  
    33import datetime 
    44import os 
     5thisdir = os.path.dirname(__file__) 
     6logname = os.path.join(thisdir, "djvtest.log") 
     7 
     8 
    59try: 
    610    import pythoncom 
     
    146150    # Remove the ID property (inherited from Unit) from the Exhibit class. 
    147151    ID = None 
    148     sequencer = dejavu.UnitSequencerNull() 
     152    sequencer = dejavu.UnitSequencer() 
    149153    identifiers = ("ZooID", Name) 
    150154 
     
    10091013            self.fail("Exhibit incorrectly possesses an ID property.") 
    10101014         
    1011         self.assertIn(source, "    sequencer = UnitSequencerNull()") 
     1015        self.assertIn(source, "    sequencer = UnitSequencer()") 
    10121016         
    10131017        if not ("    identifiers = ('ZooID', 'Name')" in source 
     
    11791183        message = message.encode('utf8') 
    11801184    s = "%s %s" % (datetime.datetime.now().isoformat(), message) 
    1181     fname = os.path.join(os.path.dirname(__file__), "djvtest.log") 
    1182     f = open(fname, 'ab') 
     1185    f = open(logname, 'ab') 
    11831186    f.write(s + '\n') 
    11841187    f.close() 
     
    12711274    finally: 
    12721275        teardown() 
    1273  
  • trunk/units.py

    r363 r364  
    1818__all__ = ['UnitAssociation', 'ToMany', 'ToOne', 'UnitJoin', 
    1919           'Unit', 'UnitProperty', 'TriggerProperty', 'MetaUnit', 
    20            'UnitSequencerInteger', 'UnitSequencerNull', 
     20           'UnitSequencerInteger', 'UnitSequencer', 
    2121           'UnitSequencerUnicode', 
    2222##           '_define_fixedpoint_states', '_fix_fixedpoint_cmp', 
     
    213213# obey the builtin max() and min() functions. 
    214214 
    215 class UnitSequencerNull(object): 
    216     """A null sequencer for Unit identifiers. Sequencing will error. 
     215class UnitSequencer(object): 
     216    """A base class for Unit identifier Sequencers. Sequencing will error. 
    217217     
    218218    In many cases, identifier values simply have no algorithmic sequence; 
     
    229229     
    230230    def valid_id(self, identity): 
     231        """If the given identity value is syntactically valid, return True. 
     232         
     233        Note that this method makes no other assertions about the given 
     234        identity; in particular, it does not check for duplicated values. 
     235        """ 
    231236        for val in identity: 
    232237            if val is None: 
     
    235240     
    236241    def assign(self, unit, sequence): 
     242        """Set a valid identifier on the given unit. 
     243         
     244        The given sequence may be used to determine the 'next' valid id. 
     245        If provided, it should be the entire set of existing identifiers. 
     246        """ 
    237247        raise StopIteration("No sequence defined.") 
    238248 
    239249 
    240 class UnitSequencerInteger(object): 
     250class UnitSequencerInteger(UnitSequencer): 
    241251    """A sequencer for Unit identifiers, where id[i+1] == id[i] + 1.""" 
    242252     
     
    257267 
    258268 
    259 class UnitSequencerUnicode(object): 
    260     """UnitSequencerUnicode(type=unicode, width=6, 
    261         range="abcdefghijklmnopqrstuvwxyz") 
    262     A sequencer for Unit identifiers, where e.g. next(['abc']) == 'abd'.""" 
     269class UnitSequencerUnicode(UnitSequencer): 
     270    """A sequencer for Unit identifiers, where next('abc') == 'abd'.""" 
    263271     
    264272    def __init__(self, type=unicode, width=6,