Changeset 164
- Timestamp:
- 05/28/02 11:19:03 (6 years ago)
- Files:
-
- trunk/RBFoundation/RBFoundation/AttributedDict.py (modified) (1 diff)
- trunk/RBFoundation/RBFoundation/ContextApply.py (modified) (5 diffs)
- trunk/RBFoundation/RBFoundation/ObjectifiedXMLParser.py (modified) (3 diffs)
- trunk/RBFoundation/RBFoundation/SmartSelect.py (modified) (3 diffs)
- trunk/RBFoundation/RBFoundation/WeakBind.py (modified) (4 diffs)
- trunk/RBFoundation/RBFoundation/XMLBuilder.py (modified) (4 diffs)
- trunk/RBFoundation/RBFoundation/XMLObjectify.py (modified) (1 diff)
- trunk/RBJabber/RBJabber/Client.py (modified) (1 diff)
- trunk/RBJabber/RBJabber/Conference.py (modified) (2 diffs)
- trunk/RBJabber/RBJabber/JID.py (modified) (2 diffs)
- trunk/RBJabber/RBJabber/JabberConnection.py (modified) (2 diffs)
- trunk/RBJabber/RBJabber/JabberSubject.py (modified) (1 diff)
- trunk/RBJabber/RBJabber/SubjectObserver/AttributedSubject.py (modified) (6 diffs)
- trunk/RBJabber/RBJabber/SubjectObserver/BidableSubject.py (modified) (2 diffs)
- trunk/RBJabber/RBJabber/SubjectObserver/StateMachine.py (modified) (1 diff)
- trunk/RBJabber/RBJabber/SubjectObserver/Subject.py (modified) (1 diff)
- trunk/RBJabber/RBJabber/Test.py (modified) (1 diff)
- trunk/RBJabber/RBJabber/iqQuery.py (modified) (1 diff)
- trunk/RBSkinning/RBSkinning/skin/reference.py (modified) (1 diff)
- trunk/RBSkinning/RBSkinning/wxTools/wxEvtHandlerBidableCategorySubject.py (modified) (1 diff)
- trunk/RBSkinning/RBSkinning/xmlPython/script.py (modified) (1 diff)
- trunk/RBSkinning/support/scripts/ImageReadyToSkin.py (modified) (1 diff)
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 1 33 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2 34 #~ Definitions trunk/RBFoundation/RBFoundation/ContextApply.py
r132 r164 36 36 37 37 import weakref 38 from WeakBind import BindCallable, BoundCallable38 from WeakBind import BindCallable, WeakBoundCallable, StrongBoundCallable 39 39 40 40 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ … … 43 43 44 44 def _JoinKW(dict1, dict2): 45 """Join two dicts without modifying either.""" 45 46 result = dict2.copy() 46 47 result.update(dict1) … … 51 52 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 52 53 53 class _ContextApply(BoundCallable): 54 class _StrongContextApply(StrongBoundCallable): 55 """Base class for adding positional and keyword based "context" to BoundCallable objects""" 56 54 57 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.""" 59 63 self.args = args 60 64 self.kw = kw 61 65 62 class ContextApply_p_s(_ContextApply): 66 class _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 80 class 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 """ 63 85 def __call__(self, *args, **kw): 64 86 return self._DoCall(args + self.args, _JoinKW(kw, self.kw)) 65 87 66 class ContextApply_s_p(_ContextApply): 88 class 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 """ 67 93 def __call__(self, *args, **kw): 68 94 return self._DoCall(self.args + args, _JoinKW(self.kw, kw)) 69 95 70 class ContextApply_p(_ContextApply): 71 def SaveParameters(self, args, kw): pass 96 class 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 72 103 def __call__(self, *args, **kw): 73 104 return self._DoCall(args, kw) 74 105 75 class ContextApply_s(_ContextApply): 106 class 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 """ 76 112 def __call__(self, *args, **kw): 77 113 return self._DoCall(self.args, self.kw) 78 114 79 class ContextApply_0(_ContextApply): 80 def SaveParameters(self, args, kw): pass 115 class 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 81 123 def __call__(self, *args, **kw): 82 124 return self._DoCall(tuple(), {}) 83 125 84 ContextApply = ContextApply_p_s 126 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 127 128 class StrongContextApply_p_s(ContextApply_p_s_mixin, _StrongContextApply): pass 129 class StrongContextApply_s_p(ContextApply_s_p_mixin, _StrongContextApply): pass 130 class StrongContextApply_p(ContextApply_p_mixin, _StrongContextApply): pass 131 class StrongContextApply_s(ContextApply_s_mixin, _StrongContextApply): pass 132 class StrongContextApply_0(ContextApply_0_mixin, _StrongContextApply): pass 133 134 class WeakContextApply_p_s(ContextApply_p_s_mixin, _WeakContextApply): pass 135 class WeakContextApply_s_p(ContextApply_s_p_mixin, _WeakContextApply): pass 136 class WeakContextApply_p(ContextApply_p_mixin, _WeakContextApply): pass 137 class WeakContextApply_s(ContextApply_s_mixin, _WeakContextApply): pass 138 class WeakContextApply_0(ContextApply_0_mixin, _WeakContextApply): pass 139 140 ContextApply_p_s = StrongContextApply_p_s 141 ContextApply_s_p = StrongContextApply_s_p 142 ContextApply_p = StrongContextApply_p 143 ContextApply_s = StrongContextApply_s 144 ContextApply_0 = StrongContextApply_0 145 146 WeakContextApply = WeakContextApply_p_s 147 StrongContextApply = StrongContextApply_p_s 148 ContextApply = StrongContextApply_p_s 85 149 86 150 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 87 151 88 152 class 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 91 161 92 162 def __call__(self, *args, **kw): 93 163 if self.idx is None: 94 return [ apply(method, args,kw) for method in self]164 return [method(*args, **kw) for method in self] 95 165 else: 166 ## There might be a faster way to do this using map? 96 167 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? 103 175 for method in self[self.idx:][1:]: 104 apply(method, args,kw)176 method(*args, **kw) 105 177 106 178 return result … … 115 187 116 188 def printit(*args, **kw): 117 print " Args:",189 print " args: ", 118 190 pprint(args) 119 print " Kw:",191 print " kw: ", 120 192 pprint(kw) 121 193 return args, kw … … 123 195 def test(Class, callback=printit): 124 196 print 125 print " Testing Class:", Class.__name__197 print "testing:", Class.__name__ 126 198 a_s = (1,2,3) 127 199 a_p = (10,20,30) 128 200 k_s = {'a':1,'b':2} 129 201 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` 133 205 return result 134 206 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 53 53 parser.EndElementHandler = self.EndElementHandler 54 54 parser.CharacterDataHandler = self.CharacterDataHandler 55 return apply(parser.Parse, args,kw)55 return parser.Parse(*args, **kw) 56 56 57 57 def ParseFile(self, *args, **kw): … … 62 62 parser.EndElementHandler = self.EndElementHandler 63 63 parser.CharacterDataHandler = self.CharacterDataHandler 64 return apply(parser.ParseFile, args,kw)64 return parser.ParseFile(*args, **kw) 65 65 66 66 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ … … 77 77 return self.EndElementHandler(name) 78 78 else: 79 return apply(super(ObjectifiedXMLParser, self).Parse, (obj,) + args,kw)79 return super(ObjectifiedXMLParser, self).Parse(obj, *args, **kw) 80 80 81 81 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ trunk/RBFoundation/RBFoundation/SmartSelect.py
r148 r164 129 129 130 130 def __call__(self, *args, **kw): 131 return apply(self.Process, args,kw)131 return self.Process(*args, **kw) 132 132 133 133 def _getReadList(self): return [x for x in self if x._NeedsRead()] … … 148 148 149 149 def __call__(self, *args, **kw): 150 return apply(self.Process, args,kw)150 return self.Process(*args, **kw) 151 151 152 152 def _getReadList(self): return [x for x in self.itervalues() if x._NeedsRead()] … … 166 166 167 167 def __call__(self, *args, **kw): 168 return apply(self.Process, args,kw)168 return self.Process(*args, **kw) 169 169 170 170 def _getReadList(self): return [x for y in self.itervalues() for x in y if x._NeedsRead()] trunk/RBFoundation/RBFoundation/WeakBind.py
r163 r164 55 55 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 56 56 57 class BoundCallable(BoundCallableBase):57 class WeakBoundCallable(BoundCallableBase): 58 58 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 59 59 #~ Constants / Variables / Etc. … … 98 98 99 99 def __eq__(self, other): 100 if isinstance(other, BoundCallable):100 if isinstance(other, WeakBoundCallable): 101 101 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 104 105 105 106 def __ne__(self, other): … … 111 112 if im_self is not None: 112 113 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) 115 116 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 119 BoundCallable = WeakBoundCallable 120 121 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 122 123 class 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) 117 158 118 159 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ … … 127 168 # Well if it requires binding, then we should 128 169 # do so! 129 return BoundCallable(callback)170 return WeakBoundCallable(callback) 130 171 else: 131 172 # not quite sure what it is, but it does not require binding trunk/RBFoundation/RBFoundation/XMLBuilder.py
r133 r164 112 112 113 113 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) 116 116 if self._elements: 117 117 self._elements[-1]._addElement(namespace, node, object) … … 156 156 """Calls ParseFile if the first argument is an open file, and Parse otherwise.""" 157 157 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) 160 160 161 161 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ … … 166 166 """Starts the building of python objects using the XML parser. Assumes first argument is string-like object.""" 167 167 parser= self._PreParse() 168 apply(parser.Parse, args,kw)168 parser.Parse(*args, **kw) 169 169 return self._PostParse(parser) 170 170 … … 172 172 """Starts the building of python objects using the XML parser. Assumes first argument is a file-like object.""" 173 173 parser= self._PreParse() 174 apply(parser.ParseFile, args,kw)174 parser.ParseFile(*args, **kw) 175 175 return self._PostParse(parser) 176 176 trunk/RBFoundation/RBFoundation/XMLObjectify.py
r151 r164 434 434 """Simple access to Objectifier.Objectify or Objectifier.ParseFile. 435 435 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) 437 437 438 438 def ObjectifyFile(*args, **kw): 439 439 """Simple access to Objectifier.ObjectifyFile or Objectifier.ParseFile. 440 440 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) 442 442 443 443 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ trunk/RBJabber/RBJabber/Client.py
r145 r164 90 90 self.information.jid = JID.JID() 91 91 self.information.authorized = 0 92 apply(self.__super.__init__, args,kw)92 self.__super.__init__(*args, **kw) 93 93 94 94 self.SupportedNS = [] trunk/RBJabber/RBJabber/Conference.py
r144 r164 98 98 # This 'subject' is defined to be from JIDs in the conference 99 99 return 0 100 return apply(self.__super.Bid, (subject,),UpdateDict)100 return self.__super.Bid(subject, **UpdateDict) 101 101 102 102 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ … … 138 138 """Invites a JID to join the conference""" 139 139 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) 141 141 142 142 def Message(self, *args, **kw): 143 143 """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) 145 145 146 146 def Presence(self, *args, **kw): 147 147 """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) 149 149 150 150 Conference._Conference__super = super(Conference) trunk/RBJabber/RBJabber/JID.py
r143 r164 84 84 def compare(*args, **kw): 85 85 """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) 87 87 88 88 def contains(strJIDa, strJIDb): … … 151 151 152 152 def join(Class, *args): 153 return Class( apply(join,args))153 return Class(join(*args)) 154 154 join = classmethod(join) 155 155 trunk/RBJabber/RBJabber/JabberConnection.py
r150 r164 50 50 from Foundation.XMLBuilder import XMLBuilderMixin, XMLBuilderObjectBase 51 51 from Foundation import SmartSelect 52 from Foundation. ContextApplyimport BindCallable52 from Foundation.WeakBind import BindCallable 53 53 import JID 54 54 import socket … … 92 92 93 93 if args or kw: 94 apply(self.Startup, args,kw)94 self.Startup(*args, **kw) 95 95 96 96 def __del__(self): trunk/RBJabber/RBJabber/JabberSubject.py
r159 r164 51 51 class FromJIDSubjectMixin(JabberSubjectBase): 52 52 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) 54 54 55 55 def RemoveObserver(self, category, observer): trunk/RBJabber/RBJabber/SubjectObserver/AttributedSubject.py
r162 r164 47 47 48 48 def __init__(self, *args, **kw): 49 apply(super(AttributedSubjectMixin, self).__init__, args,kw)49 super(AttributedSubjectMixin, self).__init__(*args, **kw) 50 50 self._attributes = {} 51 51 … … 60 60 if '_' != name[0]: 61 61 self._attributes[name] = value 62 apply(self.UpdateObservers, tuple(),{name: value})62 self.UpdateObservers(**{name: value}) 63 63 else: 64 64 return super(AttributedSubjectMixin, self).__setattr__(name, value) … … 68 68 if name in self._attributes: 69 69 del self._attributes[name] 70 apply(self.UpdateObservers, tuple(),{name: None})70 self.UpdateObservers(**{name: None}) 71 71 else: 72 72 return super(AttributedSubjectMixin, self).__delattr__(name) … … 89 89 90 90 def __getitem__(self, *args, **kw): 91 return apply(self._attributes.__getitem__, args,kw)91 return self._attributes.__getitem__(*args, **kw) 92 92 93 93 def __setitem__(self, *args, **kw): 94 return apply(self._attributes.__setitem__, args,kw)94 return self._attributes.__setitem__(*args, **kw) 95 95 96 96 def __delitem__(self, *args, **kw): 97 return apply(self._attributes.__delitem__, args,kw)97 return self._attributes.__delitem__(*args, **kw) 98 98 99 99 def __hash__(self): … … 107 107 108 108 def get(self, *args, **kw): 109 return apply(self._attributes.get, args,kw)109 return self._attributes.get(*args, **kw) 110 110 111 111 def has_key(self, *args, **kw): 112 return apply(self._attributes.has_key, args,kw)112 return self._attributes.has_key(*args, **kw) 113 113 114 114 def popitem(self, *args, **kw): 115 return apply(self._attributes.popitem, args,kw)115 return self._attributes.popitem(*args, **kw) 116 116 117 117 def setdefault(self, *args, **kw): 118 return apply(self._attributes.setdefault, args,kw)118 return self._attributes.setdefault(*args, **kw) 119 119 120 120 def update(self, *args, **kw): 121 return apply(self._attributes.update, args,kw)121 return self._attributes.update(*args, **kw) 122 122 123 123 def keys(self): … … 144 144 class AttributedSubject(AttributedSubjectMixin, Subject): 145 145 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) 148 148 trunk/RBJabber/RBJabber/SubjectObserver/BidableSubject.py
r71 r164 46 46 if bid is None: 47 47 # This client does not payattention to bids... 48 apply(observer, (self,),UpdateDict)48 observer(self, **UpdateDict) 49 49 else: 50 50 if callable(bid): 51 bid = apply(bid, (self,),UpdateDict)51 bid = bid(self, **UpdateDict) 52 52 if bid: 53 53 if bid > self._bids[0]: … … 61 61 if result and self._bids: 62 62 for observer in self._bids[-1]: 63 apply(observer, (self,),UpdateDict)63 observer(self, **UpdateDict) 64 64 result *= self._bids[-1] and 1 or 0 65 65 self._bids = None trunk/RBJabber/RBJabber/SubjectObserver/StateMachine.py
r160 r164 95 95 def AddObserver(self, callable, category='', **kw): 96 96 category = category or 'precondition' 97 return apply(CategorySubject.AddObserver, (self, category, callable),kw)97 return CategorySubject.AddObserver(self, category, callable, **kw) 98 98 99 99 def SetState(self, value =1): trunk/RBJabber/RBJabber/SubjectObserver/Subject.py
r159 r164 104 104 def UpdateObserver(self, observer, UpdateDict): 105 105 """Updates observer with UpdateDict. (UpdateDict is assumed to be a dictonary.)""" 106 if observer: apply(observer, (self,),UpdateDict)106 if observer: observer(self, **UpdateDict) 107 107 108 108 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ trunk/RBJabber/RBJabber/Test.py
r103 r164 105 105 strEval = ('{"%s"}'%strEval) 106 106 dictLogin.update(eval(strEval, {}, {})) 107 apply(_test, tuple(),dictLogin)107 _test(**dictLogin) 108 108 trunk/RBJabber/RBJabber/iqQuery.py
r135 r164 82 82 def __call__(self, *args, **kw): 83 83 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 64 64 self.ReferenceSkin(child.object) 65 65 elif isinstance(child.object, tuple): 66 apply(self.ReferenceSkin,child.object)66 self.ReferenceSkin(*child.object) 67 67 del self.__skinner 68 68 trunk/RBSkinning/RBSkinning/wxTools/wxEvtHandlerBidableCategorySubject.py
r159 r164 54 54 def AddObserver(self, category, *args, **kw): 55 55 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) 57 57 trunk/RBSkinning/RBSkinning/xmlPython/script.py
r150 r164 58 58 args = eval(self.settings['args'], self.namespace, self._getLocals(Variables)) 59 59 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 84 84 85 85 for each in endcommands: 86 apply(each[0],each[1:])86 each[0](*each[1:])
