Changeset 2
- Timestamp:
- 09/29/04 22:13:11
- Files:
-
- trunk/__init__.py (modified) (2 diffs)
- trunk/engines.py (modified) (7 diffs)
- trunk/readme.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/__init__.py
r1 r2 206 206 sequencer = UnitSequencerInteger() 207 207 208 def __init__(self ):208 def __init__(self, **kwargs): 209 209 # Copy the class _properties dict into self. 210 210 self._properties = self.__class__._properties.copy() … … 213 213 self.dirty = False 214 214 self.temporary = False 215 216 for k, v in kwargs: 217 setattr(self, k, v) 215 218 216 219 def set_property(cls, key, type=unicode, index=False, trunk/engines.py
r1 r2 43 43 _IDs = None 44 44 45 def __init__(self, Type=None):45 def __init__(self, **kwargs): 46 46 dejavu.Unit.__init__(self) 47 47 self._IDs = sets.Set() 48 48 self._mutex = threading.RLock() 49 self.Type = Type 49 50 for k, v in kwargs: 51 setattr(self, k, v) 50 52 51 53 def acquire(self): … … 124 126 """A Rule for Unit Engines.""" 125 127 126 def __init__(self, Operation=None, SetID=None, Operand=None):127 """ (Operation, SetID, Operand=(Type | logic.Expression | otherSet)128 def __init__(self, **kwargs): 129 """kw: Operation, SetID, Operand=(Type | logic.Expression | otherSet) 128 130 129 131 Expressions: … … 156 158 """ 157 159 dejavu.Unit.__init__(self) 158 self.Operation = Operation 159 self.SetID = SetID 160 if Operation == 'FILTER': 161 if not isinstance(Operand, (str, unicode)): 162 Operand = pickle.dumps(Operand) 163 self.Operand = Operand 160 161 if kwargs.get('Operation', '') == 'FILTER': 162 if not isinstance(kwargs.get('Operand'), (str, unicode)): 163 kwargs['Operand'] = pickle.dumps(kwargs['Operand']) 164 165 for k, v in kwargs: 166 setattr(self, k, v) 164 167 165 168 def __repr__(self): … … 192 195 """A factory for Unit Collections.""" 193 196 194 def __init__(self ):197 def __init__(self, **kwargs): 195 198 dejavu.Unit.__init__(self) 196 199 self.Created = datetime.datetime.today() 197 200 self.Owner = u'' 201 202 for k, v in kwargs: 203 setattr(self, k, v) 198 204 199 205 def on_forget(self): … … 238 244 except IndexError: 239 245 SetID = 1 240 newRule = UnitEngineRule(Operation, SetID, Operand) 246 newRule = UnitEngineRule(Operation=Operation, SetID=SetID, 247 Operand=Operand) 241 248 242 249 try: … … 345 352 else: 346 353 # Create a new set. 347 B = UnitCollection( A.Type)354 B = UnitCollection(Type=A.Type) 348 355 self.sets[operand] = B 349 356 B.empty = A.empty … … 358 365 def visit_CREATE(self, setID, operand): 359 366 """Create an empty set. The next instruction is responsible to fill it.""" 360 newset = UnitCollection( operand)367 newset = UnitCollection(Type=operand) 361 368 newset.empty = True 362 369 self.sets[setID] = newset trunk/readme.py
r1 r2 50 50 a = A() 51 51 b = B() 52 a.add(b) 53 Since the keys are known, take whichever is None and supply it52 a.add(b) <-- 53 Since the related keys are known, take whichever is None and supply it 54 54 from the other Unit instance. 55 55 2. Convenience function for retrieving all far classes from an association 56 56 and treating them as a list, with len, slicing, etc. 57 3. Allow Unit properties to be set in __init__() by **kwargs. 58 SM's should still go the manual route, but app developers could 59 use it to good effect. 60 4. Batched triggers: 57 3. Batched triggers: 61 58 Some pre/post triggers should be delayed until end of request, 62 59 particularly those which affect related Units. Also on_forget(), etc. … … 70 67 3. Pre-forget/post-forget. 71 68 4. on_flush (end of request) 72 5. For UnitProperty types which are mutable (like dicts), we currently have to69 4. For UnitProperty types which are mutable (like dicts), we currently have to 73 70 explicitly set dirty, because dirty only sets automatically on rebind, 74 71 not mutate. Fix if possible, or doc the heck out of it. … … 90 87 """ 91 88 92 version = "1.2. 3"89 version = "1.2.4" 93 90 94 91 changelog = """ 92 1.2.4 (): 93 1. Allow Unit properties to be set in __init__() by **kwargs. 94 SM's should still go the manual route, but app developers could 95 use it to good effect. 96 95 97 1.2.3 (9/3/04): 96 98 1. Decoupled construction of stores from arena._load() into add_store().
