Changeset 164

Show
Ignore:
Timestamp:
05/28/02 11:19:03 (6 years ago)
Author:
sholloway
Message:

Bugfixes
Conversion away from older apply syntax

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/RBFoundation/RBFoundation/AttributedDict.py

    r147 r164  
     1#!/usr/bin/env python 
     2##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     3##~ License  
     4##~  
     5##- The RuneBlade Foundation library is intended to ease some  
     6##- aspects of writing intricate Jabber, XML, and User Interface (wxPython, etc.)  
     7##- applications, while providing the flexibility to modularly change the  
     8##- architecture. Enjoy. 
     9##~  
     10##~ Copyright (C) 2002  Shane Holloway 
     11##~  
     12##~ This library is free software; you can redistribute it and/or 
     13##~ modify it under the terms of the GNU Lesser General Public 
     14##~ License as published by the Free Software Foundation; either 
     15##~ version 2.1 of the License, or any later version at your discretion. 
     16##~  
     17##~ This library is distributed in the hope that it will be useful, 
     18##~ but WITHOUT ANY WARRANTY; without even the implied warranty of 
     19##~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     20##~ Lesser General Public License for more details. 
     21##~  
     22##~ You should have received a copy of the GNU Lesser General Public 
     23##~ License along with this library; if not, write to the Free Software 
     24##~ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
     25##~ 
     26##~ 
     27##~ Shane Holloway can be reached at shane.holloway@runeblade.com, or by post at 
     28##~ 1630 Dublin Blvd. #210 
     29##~ Colorado Springs, Colorado, USA, 80918 
     30##~ 
     31##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     32 
    133#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    234#~ Definitions  
  • trunk/RBFoundation/RBFoundation/ContextApply.py

    r132 r164  
    3636 
    3737import weakref 
    38 from WeakBind import BindCallable, BoundCallable 
     38from WeakBind import BindCallable, WeakBoundCallable, StrongBoundCallable 
    3939 
    4040#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     
    4343 
    4444def _JoinKW(dict1, dict2): 
     45    """Join two dicts without modifying either.""" 
    4546    result = dict2.copy() 
    4647    result.update(dict1) 
     
    5152#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    5253 
    53 class _ContextApply(BoundCallable): 
     54class _StrongContextApply(StrongBoundCallable): 
     55    """Base class for adding positional and keyword based "context" to BoundCallable objects""" 
     56 
    5457    def __init__(self, callback, *args, **kw): 
    55         BoundCallable.__init__(self, callback) 
    56         self.SaveParameters(args, kw) 
    57  
    58     def SaveParameters(self, args, kw): 
     58        StrongBoundCallable.__init__(self, callback) 
     59        self.SaveContext(args, kw) 
     60 
     61    def SaveContext(self, args, kw): 
     62        """Saves extra paramters to be passed to the BoundCallable object.  Creates the "context" part of ContextApply.""" 
    5963        self.args = args 
    6064        self.kw = kw 
    6165 
    62 class ContextApply_p_s(_ContextApply): 
     66class _WeakContextApply(WeakBoundCallable): 
     67    """Base class for adding positional and keyword based "context" to BoundCallable objects""" 
     68 
     69    def __init__(self, callback, *args, **kw): 
     70        WeakBoundCallable.__init__(self, callback) 
     71        self.SaveContext(args, kw) 
     72 
     73    def SaveContext(self, args, kw): 
     74        """Saves extra paramters to be passed to the BoundCallable object.  Creates the "context" part of ContextApply.""" 
     75        self.args = args 
     76        self.kw = kw 
     77 
     78#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     79 
     80class ContextApply_p_s_mixin(object): 
     81    """BoundCallable object whose parameters will be "constructed" in the following order: 
     82        - Passed from calling code, 
     83        - Saved context, 
     84    """ 
    6385    def __call__(self, *args, **kw): 
    6486        return self._DoCall(args + self.args, _JoinKW(kw, self.kw)) 
    6587 
    66 class ContextApply_s_p(_ContextApply): 
     88class ContextApply_s_p_mixin(object): 
     89    """BoundCallable object whose parameters will be "constructed" in the following order: 
     90        - Saved context, 
     91        - Passed from calling code, 
     92    """ 
    6793    def __call__(self, *args, **kw): 
    6894        return self._DoCall(self.args + args, _JoinKW(self.kw, kw)) 
    6995 
    70 class ContextApply_p(_ContextApply): 
    71     def SaveParameters(self, args, kw): pass 
     96class ContextApply_p_mixin(object): 
     97    """BoundCallable object whose parameters will be "constructed" in the following order: 
     98        - Passed from calling code, 
     99 
     100    Note: This is the same as calling the BoundCallable directly, but appears here for completeness. 
     101    """ 
     102    def SaveContext(self, args, kw): pass 
    72103    def __call__(self, *args, **kw): 
    73104        return self._DoCall(args, kw) 
    74105 
    75 class ContextApply_s(_ContextApply): 
     106class ContextApply_s_mixin(object): 
     107    """BoundCallable object whose parameters will be "constructed" in the following order: 
     108        - Saved context, 
     109 
     110    Note: The parameters from the calling code will be completely ignored. 
     111    """ 
    76112    def __call__(self, *args, **kw): 
    77113        return self._DoCall(self.args, self.kw) 
    78114 
    79 class ContextApply_0(_ContextApply): 
    80     def SaveParameters(self, args, kw): pass 
     115class ContextApply_0_mixin(object): 
     116    """BoundCallable object whose parameters will be "constructed" in the following order: 
     117        - args will be an empty tuple, 
     118        - kw will be an empty dict, 
     119 
     120    Note: The parameters from both the calling code and the "context" will be completely ignored. 
     121    """ 
     122    def SaveContext(self, args, kw): pass 
    81123    def __call__(self, *args, **kw): 
    82124        return self._DoCall(tuple(), {}) 
    83125 
    84 ContextApply = ContextApply_p_s 
     126#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     127 
     128class StrongContextApply_p_s(ContextApply_p_s_mixin, _StrongContextApply): pass 
     129class StrongContextApply_s_p(ContextApply_s_p_mixin, _StrongContextApply): pass 
     130class StrongContextApply_p(ContextApply_p_mixin, _StrongContextApply): pass 
     131class StrongContextApply_s(ContextApply_s_mixin, _StrongContextApply): pass 
     132class StrongContextApply_0(ContextApply_0_mixin, _StrongContextApply): pass 
     133 
     134class WeakContextApply_p_s(ContextApply_p_s_mixin, _WeakContextApply): pass 
     135class WeakContextApply_s_p(ContextApply_s_p_mixin, _WeakContextApply): pass 
     136class WeakContextApply_p(ContextApply_p_mixin, _WeakContextApply): pass 
     137class WeakContextApply_s(ContextApply_s_mixin, _WeakContextApply): pass 
     138class WeakContextApply_0(ContextApply_0_mixin, _WeakContextApply): pass 
     139 
     140ContextApply_p_s = StrongContextApply_p_s  
     141ContextApply_s_p = StrongContextApply_s_p  
     142ContextApply_p = StrongContextApply_p  
     143ContextApply_s = StrongContextApply_s  
     144ContextApply_0 = StrongContextApply_0  
     145 
     146WeakContextApply = WeakContextApply_p_s 
     147StrongContextApply = StrongContextApply_p_s 
     148ContextApply = StrongContextApply_p_s 
    85149 
    86150#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    87151 
    88152class MultipleApply(list): 
    89     def __init__(self, ReturnIdx=-1): 
    90         self.idx = ReturnIdx  
     153    """Allows a list of callable objects to appear as a single callable object, returning the idx result. 
     154    If idx is None, will return a list of all the results. 
     155     
     156    Note: Implementation of the composite pattern. 
     157    """ 
     158    def __init__(self, idx=-1, *args, **kw): 
     159        list.__init__(self, *args, **kw) 
     160        self.idx = idx 
    91161 
    92162    def __call__(self, *args, **kw): 
    93163        if self.idx is None: 
    94             return [apply(method, args, kw) for method in self] 
     164            return [method(*args, **kw) for method in self] 
    95165        else: 
     166            ## There might be a faster way to do this using map? 
    96167            for method in self[:self.idx]: 
    97                 apply(method, args, kw) 
    98  
    99             result = apply(self[self.idx], args, kw) 
    100  
    101             # Normally you would think to just add one to ReturnNth, 
    102             # But by splitting it twice, self.ReturnNth can be -1 as well 
     168                method(*args, **kw) 
     169 
     170            result = self[self.idx](*args, **kw) 
     171 
     172            # Normally you would think to just add one to idx, 
     173            # But by splitting it twice, self.idx can be -1 as well 
     174            ## There might be a faster way to do this using map? 
    103175            for method in self[self.idx:][1:]: 
    104                 apply(method, args, kw) 
     176                method(*args, **kw) 
    105177 
    106178            return result 
     
    115187 
    116188    def printit(*args, **kw): 
    117         print "Args:",  
     189        print "   args: ",  
    118190        pprint(args) 
    119         print "Kw:",  
     191        print "     kw: ",  
    120192        pprint(kw) 
    121193        return args, kw 
     
    123195    def test(Class, callback=printit): 
    124196        print 
    125         print "Testing Class:", Class.__name__ 
     197        print "testing:", Class.__name__ 
    126198        a_s = (1,2,3) 
    127199        a_p = (10,20,30) 
    128200        k_s = {'a':1,'b':2} 
    129201        k_p = {'b':20, 'c':30} 
    130         cb = apply(Class, (callback,) + a_s, k_s) 
    131         result = apply(cb, a_p, k_p) 
    132         print "$ %s $" % `result` 
     202        cb = Class(callback, *a_s, **k_s) 
     203        result = cb(*a_p, **k_p) 
     204        print ' result:', `result` 
    133205        return result 
    134206     
    135     assert(test(ContextApply_p_s) == ((10, 20, 30, 1, 2, 3), {'a': 1, 'c': 30, 'b': 20})) 
    136     assert(test(ContextApply_s_p) == ((1, 2, 3, 10, 20, 30), {'a': 1, 'c': 30, 'b': 2})) 
    137     assert(test(ContextApply_p) == ((10, 20, 30), {'c': 30, 'b': 20})) 
    138     assert(test(ContextApply_s) == ((1, 2, 3), {'a': 1, 'b': 2})) 
    139     assert(test(ContextApply_0) == (tuple(), {})) 
    140      
     207    assert test(ContextApply_p_s) == ((10, 20, 30, 1, 2, 3), {'a': 1, 'c': 30, 'b': 20}) 
     208    assert test(ContextApply_s_p) == ((1, 2, 3, 10, 20, 30), {'a': 1, 'c': 30, 'b': 2}) 
     209    assert test(ContextApply_p) == ((10, 20, 30), {'c': 30, 'b': 20}) 
     210    assert test(ContextApply_s) == ((1, 2, 3), {'a': 1, 'b': 2}) 
     211    assert test(ContextApply_0) == (tuple(), {}) 
     212 
     213    print 
     214    print "testing:", MultipleApply.__name__ 
     215    import operator 
     216    multi = MultipleApply(None, [operator.add, operator.mul, operator.mod, printit]) 
     217    assert multi(3,4) == [7, 12, 3, ((3,4), {})] 
     218    multi.idx = 2 
     219    assert multi(3,4) == 3 
     220    multi.idx = -1 
     221    assert multi(3,4) == ((3,4), {}) 
     222     
  • trunk/RBFoundation/RBFoundation/ObjectifiedXMLParser.py

    r133 r164  
    5353        parser.EndElementHandler = self.EndElementHandler  
    5454        parser.CharacterDataHandler = self.CharacterDataHandler  
    55         return apply(parser.Parse, args, kw) 
     55        return parser.Parse(*args, **kw) 
    5656 
    5757    def ParseFile(self, *args, **kw): 
     
    6262        parser.EndElementHandler = self.EndElementHandler  
    6363        parser.CharacterDataHandler = self.CharacterDataHandler  
    64         return apply(parser.ParseFile, args, kw) 
     64        return parser.ParseFile(*args, **kw) 
    6565 
    6666#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     
    7777            return self.EndElementHandler(name) 
    7878        else: 
    79             return apply(super(ObjectifiedXMLParser, self).Parse, (obj,) + args, kw) 
     79            return super(ObjectifiedXMLParser, self).Parse(obj, *args, **kw) 
    8080 
    8181#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
  • trunk/RBFoundation/RBFoundation/SmartSelect.py

    r148 r164  
    129129 
    130130    def __call__(self, *args, **kw): 
    131         return apply(self.Process, args, kw) 
     131        return self.Process(*args, **kw) 
    132132         
    133133    def _getReadList(self): return [x for x in self if x._NeedsRead()] 
     
    148148 
    149149    def __call__(self, *args, **kw): 
    150         return apply(self.Process, args, kw) 
     150        return self.Process(*args, **kw) 
    151151         
    152152    def _getReadList(self): return [x for x in self.itervalues() if x._NeedsRead()] 
     
    166166 
    167167    def __call__(self, *args, **kw): 
    168         return apply(self.Process, args, kw) 
     168        return self.Process(*args, **kw) 
    169169         
    170170    def _getReadList(self): return [x for y in self.itervalues() for x in y if x._NeedsRead()] 
  • trunk/RBFoundation/RBFoundation/WeakBind.py

    r163 r164  
    5555#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    5656 
    57 class BoundCallable(BoundCallableBase): 
     57class WeakBoundCallable(BoundCallableBase): 
    5858    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    5959    #~ Constants / Variables / Etc.  
     
    9898 
    9999    def __eq__(self, other): 
    100         if isinstance(other, BoundCallable): 
     100        if isinstance(other, WeakBoundCallable): 
    101101            return (self.im_self == other.im_self) and (self.im_func == other.im_func)  
    102         else:  
    103             return self == BoundCallable(other) 
     102        elif callable(other):  
     103            return self == WeakBoundCallable(other) 
     104        else: return self is other 
    104105 
    105106    def __ne__(self, other): 
     
    111112            if im_self is not None:  
    112113                if self.im_func: 
    113                     return apply(self.im_func, (im_self,) + args, kw) 
    114                 else: return apply(im_self, args, kw) 
     114                    return self.im_func(im_self, *args, **kw) 
     115                else: return im_self(*args, **kw) 
    115116            else: raise weakref.ReferenceError, "weakly-referenced object no longer exists" 
    116         else: return apply(self.im_func, args, kw) 
     117        else: return self.im_func(*args, **kw) 
     118 
     119BoundCallable = WeakBoundCallable 
     120 
     121#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     122 
     123class StrongBoundCallable(BoundCallableBase): 
     124    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     125    #~ Constants / Variables / Etc.  
     126    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     127 
     128    callback = None 
     129 
     130    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     131    #~ Special  
     132    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     133 
     134    def __init__(self, callback): 
     135        if callback is None:  
     136            pass # A "None" method... it should expire immediately 
     137        elif callable(callback): 
     138            self.callback = callback 
     139 
     140    def __nonzero__(self): 
     141        return self.callback is not None and 1 or 0 
     142 
     143    def __call__(self, *args, **kw): 
     144        return self._DoCall(args, kw) 
     145 
     146    def __eq__(self, other): 
     147        if isinstance(other, StrongBoundCallable): 
     148            return self.callback == other.callback 
     149        elif callable(other):  
     150            return self == StrongBoundCallable(other) 
     151        else: return self is other 
     152 
     153    def __ne__(self, other): 
     154        return not self.__eq__(other) 
     155 
     156    def _DoCall(self, args, kw): 
     157        return self.callback(*args, **kw) 
    117158 
    118159#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     
    127168        # Well if it requires binding, then we should 
    128169        # do so! 
    129         return BoundCallable(callback) 
     170        return WeakBoundCallable(callback) 
    130171    else: 
    131172        # not quite sure what it is, but it does not require binding 
  • trunk/RBFoundation/RBFoundation/XMLBuilder.py

    r133 r164  
    112112 
    113113        args = (self._GetOwner(), self._elements and self._elements[-1] or None, namespace, node, attributes) 
    114         build_factory = apply(self._GetElementFactory, args) 
    115         object = apply(build_factory, args) 
     114        build_factory = self._GetElementFactory(*args) 
     115        object = build_factory(*args) 
    116116        if self._elements: 
    117117            self._elements[-1]._addElement(namespace, node, object) 
     
    156156        """Calls ParseFile if the first argument is an open file, and Parse otherwise.""" 
    157157        if isinstance(args[0], file): 
    158             return apply(self.ParseFile, args, kw) 
    159         else: return apply(self.Parse, args, kw) 
     158            return self.ParseFile(*args, **kw) 
     159        else: return self.Parse(*args, **kw) 
    160160 
    161161    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     
    166166        """Starts the building of python objects using the XML parser.  Assumes first argument is string-like object.""" 
    167167        parser= self._PreParse() 
    168         apply(parser.Parse, args, kw) 
     168        parser.Parse(*args, **kw) 
    169169        return self._PostParse(parser) 
    170170 
     
    172172        """Starts the building of python objects using the XML parser.  Assumes first argument is a file-like object.""" 
    173173        parser= self._PreParse() 
    174         apply(parser.ParseFile, args, kw) 
     174        parser.ParseFile(*args, **kw) 
    175175        return self._PostParse(parser) 
    176176 
  • trunk/RBFoundation/RBFoundation/XMLObjectify.py

    r151 r164  
    434434    """Simple access to Objectifier.Objectify or Objectifier.ParseFile.   
    435435    Warning: Uses a shared object from _defaultObjectifier, and therefore is not threadsafe.""" 
    436     return apply(_defaultObjectifier().Objectify, args, kw) 
     436    return _defaultObjectifier().Objectify(*args, **kw) 
    437437 
    438438def ObjectifyFile(*args, **kw): 
    439439    """Simple access to Objectifier.ObjectifyFile or Objectifier.ParseFile.   
    440440    Warning: Uses a shared object from _defaultObjectifier, and therefore is not threadsafe.""" 
    441     return apply(_defaultObjectifier().ObjectifyFile, args, kw) 
     441    return _defaultObjectifier().ObjectifyFile(*args, **kw) 
    442442 
    443443#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
  • trunk/RBJabber/RBJabber/Client.py

    r145 r164  
    9090        self.information.jid = JID.JID() 
    9191        self.information.authorized = 0 
    92         apply(self.__super.__init__, args, kw) 
     92        self.__super.__init__(*args, **kw) 
    9393         
    9494        self.SupportedNS = [] 
  • trunk/RBJabber/RBJabber/Conference.py

    r144 r164  
    9898                # This 'subject' is defined to be from JIDs in the conference 
    9999                return 0 
    100         return apply(self.__super.Bid, (subject,), UpdateDict) 
     100        return self.__super.Bid(subject, **UpdateDict) 
    101101         
    102102    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     
    138138        """Invites a JID to join the conference""" 
    139139        kw['xml'] = kw.get('xml', '') + '<x xmlns="jabber:x:conference" jid="%s"/>' % self.ConferenceJID 
    140         return apply(self.JC().Message, args, kw) 
     140        return self.JC().Message(*args, **kw) 
    141141 
    142142    def Message(self, *args, **kw): 
    143143        """Sends a message to the conference""" 
    144         return apply(self.JC().Message, (self.ConferenceJID, ) + args, kw) 
     144        return self.JC().Message(self.ConferenceJID, *args, **kw) 
    145145 
    146146    def Presence(self, *args, **kw): 
    147147        """Sends a presence to the conference""" 
    148         return apply(self.JC().Presence, (self.ConferenceJID, ) + args, kw) 
     148        return self.JC().Presence(self.ConferenceJID, *args, **kw) 
    149149 
    150150Conference._Conference__super = super(Conference) 
  • trunk/RBJabber/RBJabber/JID.py

    r143 r164  
    8484def compare(*args, **kw): 
    8585    """Same as cmp_, except returns a python truth value instead of a cmp result.""" 
    86     return 0 == apply(cmp_, args, kw) 
     86    return 0 == cmp_(*args, **kw) 
    8787 
    8888def contains(strJIDa, strJIDb): 
     
    151151  
    152152    def join(Class, *args): 
    153         return Class(apply(join, args)) 
     153        return Class(join(*args)) 
    154154    join = classmethod(join) 
    155155 
  • trunk/RBJabber/RBJabber/JabberConnection.py

    r150 r164  
    5050from Foundation.XMLBuilder import XMLBuilderMixin, XMLBuilderObjectBase 
    5151from Foundation import SmartSelect 
    52 from Foundation.ContextApply import BindCallable 
     52from Foundation.WeakBind import BindCallable 
    5353import JID 
    5454import socket 
     
    9292 
    9393        if args or kw: 
    94             apply(self.Startup, args, kw) 
     94            self.Startup(*args, **kw) 
    9595 
    9696    def __del__(self): 
  • trunk/RBJabber/RBJabber/JabberSubject.py

    r159 r164  
    5151class FromJIDSubjectMixin(JabberSubjectBase): 
    5252    def AddObserver(self, category, *args, **kw): 
    53         apply(super(FromJIDSubjectMixin, self).AddObserver, (JID.JID(category),) + args, kw) 
     53        super(FromJIDSubjectMixin, self).AddObserver(JID.JID(category), *args, **kw) 
    5454 
    5555    def RemoveObserver(self, category, observer): 
  • trunk/RBJabber/RBJabber/SubjectObserver/AttributedSubject.py

    r162 r164  
    4747 
    4848    def __init__(self, *args, **kw): 
    49         apply(super(AttributedSubjectMixin, self).__init__, args, kw) 
     49        super(AttributedSubjectMixin, self).__init__(*args, **kw) 
    5050        self._attributes = {} 
    5151 
     
    6060        if '_' != name[0]: 
    6161            self._attributes[name] = value 
    62             apply(self.UpdateObservers, tuple(), {name: value}) 
     62            self.UpdateObservers(**{name: value}) 
    6363        else: 
    6464            return super(AttributedSubjectMixin, self).__setattr__(name, value) 
     
    6868            if name in self._attributes: 
    6969                del self._attributes[name] 
    70                 apply(self.UpdateObservers, tuple(), {name: None}) 
     70                self.UpdateObservers(**{name: None}) 
    7171        else: 
    7272            return super(AttributedSubjectMixin, self).__delattr__(name) 
     
    8989 
    9090    def __getitem__(self, *args, **kw):  
    91         return apply(self._attributes.__getitem__, args, kw) 
     91        return self._attributes.__getitem__(*args, **kw) 
    9292 
    9393    def __setitem__(self, *args, **kw):  
    94         return apply(self._attributes.__setitem__, args, kw) 
     94        return self._attributes.__setitem__(*args, **kw) 
    9595 
    9696    def __delitem__(self, *args, **kw):  
    97         return apply(self._attributes.__delitem__, args, kw) 
     97        return self._attributes.__delitem__(*args, **kw) 
    9898 
    9999    def __hash__(self): 
     
    107107 
    108108    def get(self, *args, **kw):  
    109         return apply(self._attributes.get, args, kw) 
     109        return self._attributes.get(*args, **kw) 
    110110 
    111111    def has_key(self, *args, **kw):  
    112         return apply(self._attributes.has_key, args, kw) 
     112        return self._attributes.has_key(*args, **kw) 
    113113 
    114114    def popitem(self, *args, **kw):  
    115         return apply(self._attributes.popitem, args, kw) 
     115        return self._attributes.popitem(*args, **kw) 
    116116 
    117117    def setdefault(self, *args, **kw):  
    118         return apply(self._attributes.setdefault, args, kw) 
     118        return self._attributes.setdefault(*args, **kw) 
    119119 
    120120    def update(self, *args, **kw):  
    121         return apply(self._attributes.update, args, kw) 
     121        return self._attributes.update(*args, **kw) 
    122122 
    123123    def keys(self):  
     
    144144class AttributedSubject(AttributedSubjectMixin, Subject):  
    145145    def AddObserver(self, observer, call=0, **kw): 
    146         apply(Subject.AddObserver, (self, observer), kw) 
    147         if call: apply(observer, (self,), self._attributes) 
     146        Subject.AddObserver(self, observer, **kw) 
     147        if call: observer(self, **self._attributes) 
    148148 
  • trunk/RBJabber/RBJabber/SubjectObserver/BidableSubject.py

    r71 r164  
    4646        if bid is None: 
    4747            # This client does not payattention to bids...  
    48             apply(observer, (self,), UpdateDict) 
     48            observer(self, **UpdateDict) 
    4949        else: 
    5050            if callable(bid): 
    51                 bid = apply(bid, (self,), UpdateDict) 
     51                bid = bid(self, **UpdateDict) 
    5252            if bid: 
    5353                if bid > self._bids[0]: 
     
    6161        if result and self._bids: 
    6262            for observer in self._bids[-1]: 
    63                 apply(observer, (self,), UpdateDict) 
     63                observer(self, **UpdateDict) 
    6464            result *= self._bids[-1] and 1 or 0 
    6565        self._bids = None 
  • trunk/RBJabber/RBJabber/SubjectObserver/StateMachine.py

    r160 r164  
    9595    def AddObserver(self, callable, category='', **kw): 
    9696        category = category or 'precondition' 
    97         return apply(CategorySubject.AddObserver, (self, category, callable), kw) 
     97        return CategorySubject.AddObserver(self, category, callable, **kw) 
    9898 
    9999    def SetState(self, value =1): 
  • trunk/RBJabber/RBJabber/SubjectObserver/Subject.py

    r159 r164  
    104104    def UpdateObserver(self, observer, UpdateDict): 
    105105        """Updates observer with UpdateDict.  (UpdateDict is assumed to be a dictonary.)""" 
    106         if observer: apply(observer, (self,), UpdateDict) 
     106        if observer: observer(self, **UpdateDict) 
    107107 
    108108    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
  • trunk/RBJabber/RBJabber/Test.py

    r103 r164  
    105105        strEval = ('{"%s"}'%strEval) 
    106106        dictLogin.update(eval(strEval, {}, {})) 
    107     apply(_test, tuple(), dictLogin) 
     107    _test(**dictLogin) 
    108108 
  • trunk/RBJabber/RBJabber/iqQuery.py

    r135 r164  
    8282    def __call__(self, *args, **kw): 
    8383        self._serviced = 1 
    84         return apply(super(iqQuery, self).__call__, args, kw) 
     84        return super(iqQuery, self).__call__(*args, **kw) 
  • trunk/RBSkinning/RBSkinning/skin/reference.py

    r151 r164  
    6464                    self.ReferenceSkin(child.object) 
    6565                elif isinstance(child.object, tuple): 
    66                     apply(self.ReferenceSkin, child.object) 
     66                    self.ReferenceSkin(*child.object) 
    6767        del self.__skinner 
    6868 
  • trunk/RBSkinning/RBSkinning/wxTools/wxEvtHandlerBidableCategorySubject.py

    r159 r164  
    5454    def AddObserver(self, category, *args, **kw): 
    5555        self.EvtHandler.Connect(-1, -1, category, BindCallable(self._OnEvent)) 
    56         apply(BidableCategorySubject.AddObserver, (self, ('event', category)) + args, kw) 
     56        BidableCategorySubject.AddObserver(self, ('event', category), *args, **kw) 
    5757 
  • trunk/RBSkinning/RBSkinning/xmlPython/script.py

    r150 r164  
    5858        args = eval(self.settings['args'], self.namespace, self._getLocals(Variables)) 
    5959        kw = eval(self.settings['kw'], self.namespace, self._getLocals(Variables)) 
    60         return apply(call, args, kw) 
     60        return call(*args, **kw) 
  • trunk/RBSkinning/support/scripts/ImageReadyToSkin.py

    r70 r164  
    8484 
    8585    for each in endcommands: 
    86         apply(each[0], each[1:]) 
     86        each[0](*each[1:])