Changeset 162

Show
Ignore:
Timestamp:
04/28/08 23:46:43 (7 months ago)
Author:
edsuom
Message:

Parameterized.paramNames is now usable as an instance variable

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • projects/Twisted-Goodies/trunk/twisted_goodies/pybywire/params.py

    r142 r162  
    6969      subclasses self-unjellyable and allow instances of them. 
    7070     
    71     @cvar keyAttrs: A dict of attributes on which cache keying will be 
    72       partially based. Any entry having a value of C{None} has no default, and 
     71    @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 
    7373      the attribute and its value must be supplied to the constructor via a 
    7474      keyword, or set directly before use. 
    7575 
    76     @cvar paramNames: A sequence of names for my parameter. Parameter sequences 
    77       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. 
    7878 
    7979    """ 
     
    8989        When instantiated as an original (not remote) version, keywords can be 
    9090        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. 
    9293        """ 
    9394        for name, default in self.keyAttrs.iteritems(): 
     
    170171        as being safe for unjellying. 
    171172        """ 
    172         state = {'name':self.name
     173        state = {'name':self.name, 'paramNames':self.paramNames
    173174        for sequence in (self.keyAttrs.keys(), self.paramNames): 
    174175            for name in sequence: 
     
    192193        packed values present. 
    193194        """ 
     195        setattr(self, 'paramNames', state.pop('paramNames')) 
    194196        if '_packedNames' in state: 
    195197            packedNames = state.pop('_packedNames') 
  • projects/Twisted-Goodies/trunk/twisted_goodies/pybywire/test/test_params.py

    r142 r162  
    9696        # Parameterized objects have a 'name' attribute that is automatically 
    9797        # 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} 
    99101        self.failUnlessElementsEqual(state.keys(), expectedState.keys()) 
    100102        self.failUnlessElementsEqual(state.values(), expectedState.values()) 
    101  
     103     
    102104    def test_mixinMethod(self): 
    103105        self.failUnlessEqual(self.ct.mixinMethod(10), 1030) 
     
    199201        return d 
    200202 
    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