Changeset 162
- Timestamp:
- 04/28/08 23:46:43 (7 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
projects/Twisted-Goodies/trunk/twisted_goodies/pybywire/params.py
r142 r162 69 69 subclasses self-unjellyable and allow instances of them. 70 70 71 @cvar keyAttrs: A dict of attributes on which cache keying will be72 partially based. Any entry having a value of C{None} has no default, and71 @cvar keyAttrs: A dict of attributes, the updating of any of which will 72 clear my cache. Any entry having a value of C{None} has no default, and 73 73 the attribute and its value must be supplied to the constructor via a 74 74 keyword, or set directly before use. 75 75 76 @ cvar paramNames: A sequence of names for my parameter. Parameter sequences77 must be supplied to L{setParamSequence} in that order.76 @ivar paramNames: A sequence of names for my parameters (if any). Parameter 77 sequences must be supplied to L{setParamSequence} in that order. 78 78 79 79 """ … … 89 89 When instantiated as an original (not remote) version, keywords can be 90 90 supplied (in some cases, must be supplied) that specify the names and 91 values of attributes that are incorporated into the cache keying. 91 values of attributes that clear the cache upon alteration, as with 92 parameters. 92 93 """ 93 94 for name, default in self.keyAttrs.iteritems(): … … 170 171 as being safe for unjellying. 171 172 """ 172 state = {'name':self.name }173 state = {'name':self.name, 'paramNames':self.paramNames} 173 174 for sequence in (self.keyAttrs.keys(), self.paramNames): 174 175 for name in sequence: … … 192 193 packed values present. 193 194 """ 195 setattr(self, 'paramNames', state.pop('paramNames')) 194 196 if '_packedNames' in state: 195 197 packedNames = state.pop('_packedNames') projects/Twisted-Goodies/trunk/twisted_goodies/pybywire/test/test_params.py
r142 r162 96 96 # Parameterized objects have a 'name' attribute that is automatically 97 97 # included in the state 98 expectedState = {'a':1.0, 'b':2.0, 'c':3.0, 'd':4.0, 'name':None} 98 expectedState = { 99 'a':1.0, 'b':2.0, 'c':3.0, 'd':4.0, 100 'name':None, 'paramNames':self.ct.paramNames} 99 101 self.failUnlessElementsEqual(state.keys(), expectedState.keys()) 100 102 self.failUnlessElementsEqual(state.values(), expectedState.values()) 101 103 102 104 def test_mixinMethod(self): 103 105 self.failUnlessEqual(self.ct.mixinMethod(10), 1030) … … 199 201 return d 200 202 201 203 def test_instanceParamNames(self): 204 ct = Thingy() 205 ct.paramNames = list(ct.paramNames) + ['e'] 206 ct.setParamSequence(s.arange(3)) 207 d = self.getReferenceToRoot(self.CopyableReturner(ct)) 208 d.addCallback(lambda _: self.ref.callRemote("giveMeCopy", ct)) 209 d.addErrback(self._oops) 210 d.addCallback(self._checkCopy, ct, 'd', 'e', 'paramNames') 211 return d 212 213
