Changeset 364
- Timestamp:
- 12/25/06 16:33:22
- Files:
-
- trunk/doc/modeling.html (modified) (1 diff)
- trunk/schemas.py (modified) (1 diff)
- trunk/storage/db.py (modified) (2 diffs)
- trunk/test/zoo_fixture.py (modified) (5 diffs)
- trunk/units.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/doc/modeling.html
r363 r364 343 343 UnitSequencerInteger in this way.]</p> 344 344 345 <p>The other useful Sequencer is <tt>UnitSequencerNull</tt>, which simply346 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 set348 <tt>ClassA.sequencer = dejavu.UnitSequencer Null()</tt>, and form ID values345 <p>The other useful Sequencer is the base class <tt>UnitSequencer</tt>, 346 which 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 349 349 in your own code.</p> 350 350 trunk/schemas.py
r363 r364 11 11 ID = units.UnitProperty(unicode) 12 12 Version = units.UnitProperty(int) 13 sequencer = units.UnitSequencer Null()13 sequencer = units.UnitSequencer() 14 14 15 15 trunk/storage/db.py
r363 r364 658 658 659 659 class AutoUnitClass(dejavu.Unit): 660 sequencer = dejavu.UnitSequencer Null()660 sequencer = dejavu.UnitSequencer() 661 661 identifiers = tuple([k for k in table.columns 662 662 if table.columns[k].key]) … … 740 740 code.append(sequencer) 741 741 else: 742 code.append(" sequencer = UnitSequencer Null()")742 code.append(" sequencer = UnitSequencer()") 743 743 744 744 if len(code) == 1: trunk/test/zoo_fixture.py
r363 r364 3 3 import datetime 4 4 import os 5 thisdir = os.path.dirname(__file__) 6 logname = os.path.join(thisdir, "djvtest.log") 7 8 5 9 try: 6 10 import pythoncom … … 146 150 # Remove the ID property (inherited from Unit) from the Exhibit class. 147 151 ID = None 148 sequencer = dejavu.UnitSequencer Null()152 sequencer = dejavu.UnitSequencer() 149 153 identifiers = ("ZooID", Name) 150 154 … … 1009 1013 self.fail("Exhibit incorrectly possesses an ID property.") 1010 1014 1011 self.assertIn(source, " sequencer = UnitSequencer Null()")1015 self.assertIn(source, " sequencer = UnitSequencer()") 1012 1016 1013 1017 if not (" identifiers = ('ZooID', 'Name')" in source … … 1179 1183 message = message.encode('utf8') 1180 1184 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') 1183 1186 f.write(s + '\n') 1184 1187 f.close() … … 1271 1274 finally: 1272 1275 teardown() 1273 trunk/units.py
r363 r364 18 18 __all__ = ['UnitAssociation', 'ToMany', 'ToOne', 'UnitJoin', 19 19 'Unit', 'UnitProperty', 'TriggerProperty', 'MetaUnit', 20 'UnitSequencerInteger', 'UnitSequencer Null',20 'UnitSequencerInteger', 'UnitSequencer', 21 21 'UnitSequencerUnicode', 22 22 ## '_define_fixedpoint_states', '_fix_fixedpoint_cmp', … … 213 213 # obey the builtin max() and min() functions. 214 214 215 class UnitSequencer Null(object):216 """A null sequencer for Unit identifiers. Sequencing will error.215 class UnitSequencer(object): 216 """A base class for Unit identifier Sequencers. Sequencing will error. 217 217 218 218 In many cases, identifier values simply have no algorithmic sequence; … … 229 229 230 230 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 """ 231 236 for val in identity: 232 237 if val is None: … … 235 240 236 241 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 """ 237 247 raise StopIteration("No sequence defined.") 238 248 239 249 240 class UnitSequencerInteger( object):250 class UnitSequencerInteger(UnitSequencer): 241 251 """A sequencer for Unit identifiers, where id[i+1] == id[i] + 1.""" 242 252 … … 257 267 258 268 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'.""" 269 class UnitSequencerUnicode(UnitSequencer): 270 """A sequencer for Unit identifiers, where next('abc') == 'abd'.""" 263 271 264 272 def __init__(self, type=unicode, width=6,
