Changeset 29

Show
Ignore:
Timestamp:
02/29/08 08:20:45 (10 months ago)
Author:
skit
Message:

Commit du taf des vacances

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • project/trunk/src/pyxoo/command.py

    r26 r29  
    518518        """ 
    519519        Registers the passed-in command to be triggered at each time 
    520         the controller will receive an event of type eventName>
     520        the controller will receive an event of type eventName
    521521 
    522522        If there is already a class or a command associated with the passed-in 
  • project/trunk/src/pyxoo/core.py

    r26 r29  
    172172            self.register( key, value ) 
    173173  
    174     def matchType(self, object): 
     174    def matchType( self, object ): 
    175175        """ 
    176176        Verify that the passed-in object type match the current  
     
    181181        return isinstance( object, self.getType() ) or object is None 
    182182     
    183     def getType(self): 
     183    def getType( self ): 
    184184        """ 
    185185        Return the class type of elements in this container. 
     
    191191        return self.__type 
    192192     
    193     def isTyped(self): 
     193    def isTyped( self ): 
    194194        """ 
    195195        Returns true if this container perform a verification 
     
    231231        return self.__eventBroadcaster.removeEventListener( eventType, listener ) 
    232232     
    233     def getKeys(self): 
     233    def getKeys( self ): 
    234234        """ 
    235235        Returns an list view of the keys contained in this locator. 
     
    238238        return self._elements.getKeys() 
    239239     
    240     def getValues(self): 
     240    def getValues( self ): 
    241241        """ 
    242242        Returns an list view of the values contained in this locator. 
     
    254254                 
    255255                 
     256                 
     257class Accessor( pyxoo.utils.Interface ): 
     258    """ 
     259    The Accessor interface defines common rules 
     260    to create abstract access to properties or methods of an  
     261    object. That interface allow tweens to get and set both 
     262    properties and methods of an object in a transparent way.  
     263 
     264    An Accessor could access to only one property or 
     265    getter/setter pair of methods for an object. To access many 
     266    properties/methods in one time see the AccessorComposer 
     267    interface. 
     268 
     269    In order to the accessor to get or set value with methods, an accessor 
     270    must know both getter and setter methods name. If one of these information 
     271    is not available, the accessor must throw an exception in order to prevent 
     272    the tween to work on unavailable data. 
     273 
     274    There isn't any method to dynamically bind an accessor to a new property or 
     275    a new getter/setter pair of method. You have to create a new accessor if you 
     276    need to change the property you want to access. 
     277 
     278    Note : Of course, only public members of the target object could be accessed 
     279    by an accessor instance. 
     280    """ 
     281     
     282    def getValue( self ): 
     283        """ 
     284        Retreives the value from the target property. 
     285        If the type of the data stored by this object is not 
     286        a number type, the call must fail with an exception. 
     287        @rtype: int, float, long 
     288        @return: current value stored in the target property 
     289        @raise TypeError: The target getter method doesn't return a number. 
     290        """ 
     291         
     292    def setValue( self, value ): 
     293        """ 
     294        Defines the new value for the target property. 
     295        If the type of the data stored by this object is not 
     296        a number type, the call must fail with an exception. 
     297        @param value: new numeric value for the target property 
     298        @type value: int, float, long 
     299        """ 
     300         
     301    def getTarget( self ): 
     302        """ 
     303        Returns the target object onto which this accessor operate. 
     304        @rtype: Object 
     305        @return: the object onto which this accessor operate 
     306        """ 
     307         
     308    def getGetterHelper( self ): 
     309        """ 
     310        Returns the string name of the getter access used 
     311        by this accessor to retreive data from its target object. 
     312        @rtype: String 
     313        @return: the string name of the getter access used by this accessor 
     314        """ 
     315         
     316    def getSetterHelper( self ): 
     317        """ 
     318        Returns the string name of the setter access used 
     319        by this accessor to defines new data to its target object. 
     320        @rtype: String 
     321        @return: the string name of the setter access used by this accessor 
     322        """ 
     323         
     324         
     325class MethodAccessor( Accessor ): 
     326    """ 
     327    The MethodAccessor provides read and write access  
     328    to the specified method of an object.  
     329    """ 
     330     
     331    def __init__( self, target, setter, getter ): 
     332        """ 
     333        Creates a new MethodAccessor instance which 
     334        allow access to the specified getter and 
     335        setter methods of the passed-in object. 
     336        @param target: object onto which access methods 
     337        @type target: Object 
     338        @param setter: name of the setter method on the object 
     339        @type setter: String 
     340        @param getter: name of the getter method on the object 
     341        @type getter: String 
     342        @raise pyxoo.exceptions.NullPointerException: Can't create an accessor on a null object 
     343        @raise pyxoo.exceptions.NoSuchMethodException: There is no setter method of the specified name 
     344        @raise pyxoo.exceptions.NoSuchMethodException: There is no getter method of the specified name 
     345        """ 
     346        if not target: 
     347            raise pyxoo.exceptions.NullPointerException( "Can't create an accessor on a null object" ) 
     348        elif not hasattr( target, setter ): 
     349            raise pyxoo.exceptions.NoSuchMethodException( "%s doesn't own any setter method called '%s'"%( target, setter ) ) 
     350        elif not hasattr( target, getter ): 
     351            raise pyxoo.exceptions.NoSuchMethodException( "%s doesn't own any getter method called '%s'"%( target, getter ) ) 
     352        self.__target = target 
     353        self.__setter = setter 
     354        self.__getter = getter 
     355        self.__Fsetter = getattr( target, setter ) 
     356        self.__Fgetter = getattr( target, getter ) 
     357     
     358    def getValue ( self ): 
     359        """ 
     360        Retreives the value from the target property. 
     361        If the type of the data stored by this object is not 
     362        a number type, the call must fail with an exception. 
     363        @rtype: int, float, long 
     364        @return: current value stored in the target property 
     365        @raise TypeError: The target getter method doesn't return a number. 
     366        """ 
     367        n = self.__Fgetter() 
     368        if not pyxoo.utils.Type.isNumber( n ): 
     369            raise TypeError( "%s.%s() doesn't return a number"%( self.__target, self.__getter ) ) 
     370        return n 
     371         
     372    def setValue( self, value ): 
     373        """ 
     374        Defines the new value for the target property. 
     375        If the type of the data stored by this object is not 
     376        a number type, the call must fail with an exception. 
     377        @param value: new numeric value for the target property 
     378        @type value: int, float, long 
     379        """ 
     380        self.__Fsetter( value ) 
     381         
     382    def getTarget( self ): 
     383        """ 
     384        Returns the target object onto which this accessor operate. 
     385        @rtype: Object 
     386        @return: the object onto which this accessor operate 
     387        """ 
     388        return self.__target 
     389         
     390    def getGetterHelper( self ): 
     391        """ 
     392        Returns the string name of the getter access used 
     393        by this accessor to retreive data from its target object. 
     394        @rtype: String 
     395        @return: the string name of the getter access used by this accessor 
     396        """ 
     397        return self.__getter 
     398         
     399    def getSetterHelper( self ): 
     400        """ 
     401        Returns the string name of the setter access used 
     402        by this accessor to defines new data to its target object. 
     403        @rtype: String 
     404        @return: the string name of the setter access used by this accessor 
     405        """ 
     406        return self.__setter 
     407     
     408    def __str__( self ): 
     409        """__str__():String 
     410        Returns the string representation of this instance.""" 
     411        return pyxoo.utils.PyxooStringifier.stringify( self ) 
     412 
     413     
     414class PropertyAccessor( Accessor ): 
     415    """ 
     416    The PropertyAccessor provides read and write access  
     417    to the specified property of an object.  
     418    """ 
     419    def __init__( self, target, property ): 
     420        if not target: 
     421            raise pyxoo.exceptions.NullPointerException( "Can't create an accessor on a null object" ) 
     422        elif not hasattr( target, property ): 
     423            raise pyxoo.exceptions.NoSuchFieldException( "%s doesn't own any property called '%s'"%( target, property ) ) 
     424        self.__target = target 
     425        self.__property = property 
     426         
     427         
     428    def getValue( self ): 
     429        """ 
     430        Retreives the value from the target property. 
     431        If the type of the data stored by this object is not 
     432        a number type, the call must fail with an exception. 
     433        @rtype: int, float, long 
     434        @return: current value stored in the target property 
     435        @raise TypeError: The target getter method doesn't return a number. 
     436        """ 
     437        n = getattr( self.__target, self.__property ) 
     438        if not pyxoo.utils.Type.isNumber( n ): 
     439            raise TypeError( "%s.%s() doesn't return a number"%( self.__target, self.__getter ) ) 
     440        return n 
     441         
     442    def setValue( self, value ): 
     443        """ 
     444        Defines the new value for the target property. 
     445        If the type of the data stored by this object is not 
     446        a number type, the call must fail with an exception. 
     447        @param value: new numeric value for the target property 
     448        @type value: int, float, long 
     449        """ 
     450         
     451        setattr( self.__target, self.__property, value ) 
     452         
     453    def getTarget( self ): 
     454        """ 
     455        Returns the target object onto which this accessor operate. 
     456        @rtype: Object 
     457        @return: the object onto which this accessor operate 
     458        """ 
     459        return self.__target 
     460         
     461    def getGetterHelper( self ): 
     462        """ 
     463        Returns the string name of the getter access used 
     464        by this accessor to retreive data from its target object. 
     465        @rtype: String 
     466        @return: the string name of the getter access used by this accessor 
     467        """ 
     468        return self.__property 
     469         
     470    def getSetterHelper( self ): 
     471        """ 
     472        Returns the string name of the setter access used 
     473        by this accessor to defines new data to its target object. 
     474        @rtype: String 
     475        @return: the string name of the setter access used by this accessor 
     476        """ 
     477        return self.__property 
     478     
     479    def getProperty( self ): 
     480        """ 
     481        Returns the property's name onto which this accessor operate. 
     482        """ 
     483        return self.__property 
     484     
     485    def __str__( self ): 
     486        """__str__():String 
     487        Returns the string representation of this instance.""" 
     488        return pyxoo.utils.PyxooStringifier.stringify( self ) 
     489                 
     490                 
     491class AccessorFactory: 
     492    """ 
     493    A factory for Accessor and AccessorComposer creation. 
     494    With the AccessorFactory, you don't have to know if you attempt to 
     495    access to a property or to a method. The creational methods of the factory 
     496    will return the corresponding concret accessor. 
     497    """ 
     498     
     499    @classmethod 
     500    def getAccessor( cls, target , setter, getter=None ): 
     501        """ 
     502        Returns an accessor object for the passed-in property or methods of the 
     503        specified target object. The concret type of the accessor cannot be 
     504        known before the call, as for any other factories. 
     505 
     506        In the case of accessing to method member, the setter and  
     507        getter arguments must be set. 
     508        @param target: the object onto which access member(s) 
     509        @type target: Object 
     510        @param setter: name of the setter property on the target 
     511        @type setter: String 
     512        @param getter: name of the getter property on the target, used only if the setter property is a function 
     513        @type getter: String 
     514        @rtype: pyxoo.core.Accessor 
     515        @raise pyxoo.exceptions.NullPointerException: Can't create an accessor on a null object 
     516        @raise pyxoo.exceptions.NoSuchFieldException: The target object doesn't own any field named as setter 
     517        @raise pyxoo.exceptions.NoSuchMethodExceptio: There'is no getter method to associate with the corresponding setter 
     518        """ 
     519        if not target: 
     520            raise pyxoo.exceptions.NullPointerException( "Can't create an accessor on a null object" )         
     521        if not hasattr( target, setter ): 
     522            raise pyxoo.exceptions.NoSuchFieldException( "%s doesn't own any property called '%s'"%( target, setter ) ) 
     523        elif callable( getattr( target, setter ) ): 
     524            if not getter or not hasattr( target, getter ): 
     525                raise pyxoo.exceptions.NoSuchMethodException( "%s doesn't own any getter method named %s"%( target, getter ) ) 
     526            return MethodAccessor( target, setter, getter ) 
     527        else: 
     528            return PropertyAccessor( target, setter ) 
     529         
     530         
  • project/trunk/src/pyxoo/event.py

    r23 r29  
    143143        parameter. 
    144144        """ 
    145         if target is None:self.__target = self 
    146         else:self.__target = target         
     145        if target is None:self._target = self 
     146        else:self._target = target         
    147147        self.setListenerType( listenerType ) 
    148148        self.__init() 
     
    367367        if not isinstance( event, IEvent ): 
    368368            raise TypeError( "event param must be an instance of IEvent class." )    
    369         if pyxoo.utils.Type.isNone( event.getTarget() ): 
    370             event.setTarget( self.__target )              
     369        if not event.getTarget(): 
     370            event.setTarget( self._target )              
    371371        if self.hasListenerCollection( event.getType() ): 
    372             self.__broadcast( self.getListenerCollection( event.getType() ), event ) 
    373         self.__broadcast( self.__listeners, event )             
     372            self._broadcast( self.getListenerCollection( event.getType() ), event ) 
     373        self._broadcast( self.__listeners, event )             
    374374             
    375     def __broadcast( self, listeners, event ):         
     375    def _broadcast( self, listeners, event ):    
     376        eventType = event.getType()      
    376377        for listener in listeners: 
    377             if hasattr( listener, event.getType() ) and callable( getattr( listener, event.getType() ) ): 
    378                 getattr( listener, event.getType() )( event ) 
     378            if hasattr( listener, eventType ) and callable( getattr( listener, eventType ) ): 
     379                getattr( listener, eventType )( event ) 
    379380            elif hasattr( listener, "handleEvent" ) and callable( getattr( listener, "handleEvent" ) ): 
    380381                listener.handleEvent( event ) 
    381382            else: 
    382                 raise pyxoo.exceptions.UnsupportedOperationError( "EventBroadcaster.broadcastEvent() failed, you must implement '%s' method in '%s' class."%( event.getType(), listener.__class__.__name__ ) ) 
     383                raise pyxoo.exceptions.UnsupportedOperationError( "EventBroadcaster.broadcastEvent() failed, you must implement '%s' method in '%s' class."%( eventType, listener.__class__.__name__ ) ) 
    383384     
    384385    def __storeRef( self, type, listener ): 
     
    711712        if privateAccess is not self.__PRIVATE: 
    712713            raise IllegalAccessException( "Constructor of ApplicationBroadcaster is private." ) 
    713         ChannelBroadcaster.__init__( self, _InternalBroadcaster, ApplicationBroadcaster.SYSTEM_CHANNEL ) 
     714        ChannelBroadcaster.__init__( self, pyxoo.plugin.PluginBroadcaster, ApplicationBroadcaster.SYSTEM_CHANNEL ) 
    714715 
    715716    def getChannelDispatcher( self, eventChannel=None, owner=None ): 
     
    729730 
    730731 
    731 class _InternalBroadcaster( EventBroadcaster ): 
    732      
    733     def __broadcast( self, listeners, event ):         
     732class _InternalBroadcaster( EventBroadcaster ):     
     733    def _broadcast( self, listeners, event ):         
    734734        for listener in listeners: 
    735             if hasattr( listener, event.getType() ) and callable( getattr( listener, event.getType() ) ) and event.getTarget() != listener: 
    736                 getattr( listener, event.getType() )( event ) 
    737             elif hasattr( listener, "handleEvent" ) and callable( getattr( listener, "handleEvent" ) ): 
    738                 listener.handleEvent( event ) 
    739             else: 
    740                 raise UnsupportedOperationError( "EventBroadcaster.broadcastEvent() failed, you must implement '%s' method in '%s' class."%( event.getType(), listener.__class__.__name__ ) ) 
    741      
     735            try:   
     736                if listener != event.getTarget():                     
     737                    getattr( listener, event.getType() )( event ) 
     738            except (AttributeError, TypeError):                                    
     739                try: 
     740                    listener.handleEvent( event )  
     741                except (AttributeError, TypeError): 
     742                    raise pyxoo.exceptions.UnsupportedOperationError( "EventBroadcaster.broadcastEvent() failed, you must implement '%s' method in '%s' class."%( event.getType(), listener.__class__.__name__ ) ) 
    742743 
    743744 
     
    815816class BooleanEvent( BasicEvent ): 
    816817    """BooleanEvent defines specific event structure to work with Boolean value"""     
    817     def __init__( self, eventType, value ):   
     818    def __init__( self, eventType, target=None, value=None ):   
    818819        """__init__(String, Boolean) 
    819820        Constructs a new BooleanEvent instance.""" 
    820         BasicEvent.__init__( self, eventType
     821        BasicEvent.__init__( self, eventType, target
    821822        if not Type.isBoolean( value ): 
    822823            raise TypeError( "value must be a boolean" ) 
     
    832833class IntegerEvent( BasicEvent ): 
    833834    """IntegerEvent defines specific event structure to work with Integer value"""     
    834     def __init__( self, eventType, value ):    
     835    def __init__( self, eventType, target=None, value=None ):    
    835836        """Constructs a new IntegerEvent instance.""" 
    836         BasicEvent.__init__( self, eventType
    837         if not pyxoo.utils.Type.isInt( value ): 
     837        BasicEvent.__init__( self, eventType, target
     838        if value is not None and not pyxoo.utils.Type.isInt( value ): 
    838839            raise TypeError( "value must be an integer" ) 
    839840        self.__integer = value 
     
    847848class LongEvent( BasicEvent ): 
    848849    """LongEvent defines specific event structure to work with Long Integer value"""     
    849     def __init__( self, eventType, value ):    
     850    def __init__( self, eventType, target=None, value=None ):    
    850851        """Constructs a new IntegerEvent instance.""" 
    851         BasicEvent.__init__( self, eventType
     852        BasicEvent.__init__( self, eventType, target
    852853        if not pyxoo.utils.Type.isLong( value ): 
    853854            raise TypeError( "value must be a long integer" ) 
     
    862863class FloatEvent( BasicEvent ): 
    863864    """FloatEvent defines specific event structure to work with Float value"""     
    864     def __init__( self, eventType, value ): 
     865    def __init__( self, eventType, target=None, value=None ): 
    865866        """Constructs a new FloatEvent instance."""    
    866         BasicEvent.__init__( self, eventType
     867        BasicEvent.__init__( self, eventType, target
    867868        if not Type.isFloat( value ): 
    868869            raise TypeError( "value must be a float" ) 
     
    877878class StringEvent( BasicEvent ):  
    878879    """StringEvent defines specific event structure to work with String value"""        
    879     def __init__( self, eventType, value ): 
     880    def __init__( self, eventType, target=None, value=None ): 
    880881        """Constructs a new StringEvent instance.""" 
    881         BasicEvent.__init__( self, eventType
    882         if not Type.isString( value ): 
     882        BasicEvent.__init__( self, eventType, target
     883        if value and not pyxoo.utils.Type.isString( value ): 
    883884            raise TypeError( "value must be a String" ) 
    884885        self.__string = value 
     
    892893class ValueObjectEvent( BasicEvent ): 
    893894    """ValueObjectEvent defines specific event structure to work with ValueObject value"""        
    894     def __init__( self, eventType, value ): 
     895    def __init__( self, eventType, target=None, value=None ): 
    895896        """Constructs a new ValueObjectEvent instance.""" 
    896         BasicEvent.__init__( self, eventType
     897        BasicEvent.__init__( self, eventType, target
    897898        if not isinstance( value, ValueObject ): 
    898899            raise TypeError( "value must be a ValueObject" ) 
     
    964965            time.sleep( self.__delay ) 
    965966     
    966     def start(self): 
     967    def start( self ): 
    967968        self.__running = True 
    968         threading.Thread.start(self
     969        threading.Thread.start( self
    969970      
    970971    def stop( self ): 
  • project/trunk/src/pyxoo/exceptions.py

    r25 r29  
    1111 
    1212class NoSuchElementException( Exception ): 
     13    pass 
     14 
     15class NoSuchMethodException( Exception ): 
     16    pass 
     17 
     18class NoSuchFieldException( Exception ): 
     19    pass 
     20 
     21class IndexOutOfBoundsException( Exception ): 
    1322    pass 
    1423 
     
    3241    pass 
    3342 
    34  
    3543class NullPointerException( Exception ): 
    3644    pass 
  • project/trunk/src/pyxoo/plugin.py

    r26 r29  
    4343        self.__modelLocator = pyxoo.model.ModelLocator.getInstance( self ) 
    4444        self.__viewLocator  = pyxoo.view.ViewLocator.getInstance( self ) 
    45          
    46         self.__ebExternal   = pyxoo.event.ApplicationBroadcaster.getInstance() 
     45 
    4746        self.__ebPublic     = pyxoo.event.ApplicationBroadcaster.getInstance().getChannelDispatcher( self.getChannel(), self ) 
    48         self.__ebPrivate    = pyxoo.event.EventBroadcaster( self ) 
    49         self.__ebPrivate.addListener( self.__controller ) 
    50          
     47 
    5148        if self.__ebPublic: 
    5249            self.__ebPublic.addListener( self ) 
     
    7976        """fireExternalEvent(IEvent, EventChannel):void""" 
    8077        if eventChannel != self.getChannel(): 
    81             self.__ebExternal.broadcastEvent( event, eventChannel ) 
     78            pyxoo.event.ApplicationBroadcaster.getInstance().broadcastEvent( event, eventChannel ) 
    8279     
    8380    def firePublicEvent( self, event ): 
    8481        """firePublicEvent(IEvent):void""" 
    8582        if self.__ebPublic: 
    86             self.__ebPublic.broadcastEvent( event
     83            self.__ebPublic.firePublicEvent( event, self
    8784     
    8885    def firePrivateEvent( self, event ): 
    8986        """firePrivateEvent(IEvent):void""" 
    90         self.__ebPrivate.broadcastEvent( event ) 
     87        self.__controller.handleEvent( event ) 
    9188         
    9289    def handleEvent( self, event=None ): 
     
    135132            return self.__ebPublic.removeEventListener( type, listener ) 
    136133        return False 
    137      
     134 
     135 
    138136class PluginChannel( pyxoo.event.EventChannel ): 
    139137    __instances = pyxoo.utils.HashMap() 
     
    228226 
    229227 
    230  
    231  
    232228class NullPlugin( Plugin ): 
    233229    __instance = None 
     
    277273        """getViewLocator():ViewLocator""" 
    278274        return pyxoo.view.ViewLocator.getInstance( self ) 
     275     
     276     
     277class PluginBroadcaster( pyxoo.event.EventBroadcaster ): 
     278     
     279    def firePublicEvent(self, event, owner): 
     280        if not event.getTarget(): 
     281            event.setTarget( self._target ) 
     282        eventType = event.getType() 
     283        if self.hasListenerCollection( eventType ): 
     284            for listener in self.getListenerCollection( eventType ): 
     285                if listener != owner: 
     286                    if hasattr( listener, eventType ) and callable( getattr( listener, eventType ) ): 
     287                        getattr( listener, eventType )( event ) 
     288                    elif hasattr( listener, "handleEvent" ) and callable( getattr( listener, "handleEvent" ) ): 
     289                        listener.handleEvent( event ) 
     290                    else: 
     291                        raise pyxoo.exceptions.UnsupportedOperationError( "EventBroadcaster.broadcastEvent() failed, you must implement '%s' method in '%s' class."%( eventType, listener.__class__.__name__ ) ) 
     292        for listener in self.getListenerCollection(): 
     293            if listener != owner: 
     294                if hasattr( listener, eventType ) and callable( getattr( listener, eventType ) ): 
     295                    getattr( listener, eventType )( event ) 
     296                elif hasattr( listener, "handleEvent" ) and callable( getattr( listener, "handleEvent" ) ): 
     297                    listener.handleEvent( event ) 
     298                else: 
     299                    raise pyxoo.exceptions.UnsupportedOperationError( "EventBroadcaster.broadcastEvent() failed, you must implement '%s' method in '%s' class."%( eventType, listener.__class__.__name__ ) ) 
     300     
     301                 
     302         
  • project/trunk/src/pyxoo/utils/interface.py

    r25 r29  
    1313    def __init__( self, name, parents, attributs ): 
    1414        if len( parents ) == 0:return 
    15         self.__name      = name 
     15        self.__interfaceName      = name 
    1616        self.__parents   = list( parents ) 
    1717        self.__attributs = attributs         
     
    2626            if type( att ) == types.FunctionType: 
    2727                if self.__isInterface and att.__name__ == "__init__": 
    28                     raise pyxoo.exceptions.UnsupportedOperationError( "'" + self.__name + "' is an interface. It can not contain constructor." ) 
     28                    raise pyxoo.exceptions.UnsupportedOperationError( "'" + self.__interfaceName + "' is an interface. It can not contain constructor." ) 
    2929                self.__methods[att.__name__] = att 
    3030         
     
    4848                        try: 
    4949                            if self.__methods[parent_method_name].func_code.co_argcount != parent_method.func_code.co_argcount: 
    50                                 raise NotImplementedError( "'" + self.__name + "' class implement '" + parent.getInterfaceName() + "' interface but " + parent_method.__name__ + str( parent_method.func_code.co_varnames ) + " method is not implemented." )   
     50                                raise NotImplementedError( "'" + self.__interfaceName + "' class implement '" + parent.getInterfaceName() + "' interface but " + parent_method.__name__ + str( parent_method.func_code.co_varnames ) + " method is not implemented." )   
    5151                        except( KeyError ): 
    52                             raise NotImplementedError( "'" + self.__name + "' class implement '" + parent.getInterfaceName() + "' interface but " + parent_method.__name__ + str( parent_method.func_code.co_varnames ) + " method is not implemented." )   
     52                            raise NotImplementedError( "'" + self.__interfaceName + "' class implement '" + parent.getInterfaceName() + "' interface but " + parent_method.__name__ + str( parent_method.func_code.co_varnames ) + " method is not implemented." )   
    5353 
    5454    def getInterfaceName( self ): 
    55         return self.__name 
     55        return self.__interfaceName 
    5656     
    5757    def getParents( self ): 
     
    6868     
    6969    def __str__(self): 
    70         return self.__name 
     70        return self.__interfaceName 
    7171 
    7272 
  • project/trunk/src/pyxoo/view.py

    r25 r29  
    1111    __owner = None 
    1212    __name  = None 
     13    onInitEVENT = "onInit" 
     14    onReleaseEVENT = "onRelease" 
    1315     
    1416    def __init__( self, owner=None, name=None ): 
     
    2325     
    2426    def onInit( self ): 
    25         """onInit():void""" 
    26         pass 
     27        """ 
     28        """ 
     29        self.notifyChanged( pyxoo.event.StringEvent( AbstractView.onInitEVENT, self, self.getName() ) ) 
    2730     
     31    def onRelease(self): 
     32        """ 
     33        """ 
     34        self.notifyChanged( pyxoo.event.StringEvent( AbstractView.onReleaseEVENT, self, self.getName() ) ) 
     35         
    2836    def notifyChanged( self, event ): 
    2937        """notifyChanged(IEvent):void""" 
     
    3442        self._getBroadcaster().removeAllListeners() 
    3543        pyxoo.view.ViewLocator.getInstance( self.getOwner() ).unregister( self.getName() ) 
     44        self.onRelease() 
     45        self.__name = None 
    3646     
    3747    def getOwner( self ): 
     
    5767            raise TypeError( "name param must be a String" )  
    5868        locator = pyxoo.view.ViewLocator.getInstance( self.getOwner() ) 
    59         if name and not locator.isRegistered( name ): 
    60             if locator.isRegistered( self.getName() ): 
     69        if name and not locator.isRegistered( name ):                      
     70            if locator.isRegistered( self.getName() ):                 
    6171                locator.unregister( self.getName() ) 
    62             if locator.register( name, self ): 
    63                 self.__name = name 
     72            locator.register( name, self ) 
     73            self.__name = name 
    6474         
    6575    def addListener( self, listener ): 
  • project/trunk/test/commands/TestFrontController.py

    r26 r29  
    3939 
    4040    def testHandleEvent( self ): 
    41         event = pyxoo.event.IntegerEvent( "azerty", 100 ) 
     41        event = pyxoo.event.IntegerEvent( "azerty", None, 100 ) 
    4242        command = MyCommand() 
    4343        self.instance.pushCommandInstance( "azerty", command ) 
  • project/trunk/test/events/TestChannelBroadcaster.py

    r21 r29  
    3333        self.instance = pyxoo.event.ChannelBroadcaster( None, self.channel1 ) 
    3434        self.type     = "notify" 
    35         self.event    = pyxoo.event.IntegerEvent( self.type, 1 ) 
     35        self.event    = pyxoo.event.IntegerEvent( self.type, None, 1 ) 
    3636        self.listener = self 
    3737        self.__model  = 0 
  • project/trunk/test/events/TestEventBroadcaster.py

    r21 r29  
    152152    def testBroadcastEvent( self ): 
    153153        self.instance.addEventListener( self.eventType, self ) 
    154         myEvent = pyxoo.event.IntegerEvent( self.eventType, 1 ) 
     154        myEvent = pyxoo.event.IntegerEvent( self.eventType, None, 1 ) 
    155155        self.instance.broadcastEvent( myEvent ) 
    156156        self.assertEquals( myEvent.getTarget(), self.instance )         
     
    158158        class A:pass 
    159159        a = A() 
    160         myEvent = pyxoo.event.IntegerEvent( self.eventType, 0 ) 
     160        myEvent = pyxoo.event.IntegerEvent( self.eventType, None, 0 ) 
    161161        myEvent.setTarget( a ) 
    162162        self.instance.broadcastEvent( myEvent ) 
     
    165165    def testBroadcastEventFail( self ): 
    166166        self.instance.addListener( self ) 
    167         event = pyxoo.event.IntegerEvent( "coucou", 0 )         
     167        event = pyxoo.event.IntegerEvent( "coucou", None, 0 )         
    168168        self.assertRaises( pyxoo.exceptions.UnsupportedOperationError, self.instance.broadcastEvent, event ) 
    169169         
    170170    def testAnotherBroadcastEvent( self ): 
    171171        self.instance.addListener( self ) 
    172         myEvent = pyxoo.event.IntegerEvent( self.eventType, 10 ) 
     172        myEvent = pyxoo.event.IntegerEvent( self.eventType, None, 10 ) 
    173173        self.instance.broadcastEvent( myEvent ) 
    174174        self.assertEquals( myEvent.getTarget(), self.instance )         
     
    189189        self.assertTrue( self.instance.isRegistered( myFunction, "coucou" ) ) 
    190190         
    191         myEvent = pyxoo.event.IntegerEvent( self.eventType, 10 ) 
     191        myEvent = pyxoo.event.IntegerEvent( self.eventType, None, 10 ) 
    192192        self.instance.broadcastEvent( myEvent ) 
    193193        self.assertEquals( self.instance, myEvent.getTarget() ) 
     
    200200        self.assertTrue( self.instance.isRegistered( myFunction, "coucou" ) ) 
    201201        self.assertTrue( self.instance.removeEventListener( "coucou", myFunction ) ) 
    202         myEvent = pyxoo.event.IntegerEvent( self.eventType, 0 ) 
     202        myEvent = pyxoo.event.IntegerEvent( self.eventType, None, 0 ) 
    203203        self.instance.broadcastEvent( myEvent ) 
    204204        self.assertEquals( 0, myEvent.getInteger() ) 
  • project/trunk/test/view/TestViewLocator.py

    r24 r29  
    5252    def testUnregisterView( self ): 
    5353        self.instance.register( "v1", self.view ) 
    54         self.instance.register( "v2", pyxoo.view.AbstractView() ) 
     54        view = pyxoo.view.AbstractView() 
     55        self.instance.register( "v2", view ) 
    5556        self.assertTrue( self.instance.isRegistered( "v1" ) ) 
    5657        self.assertTrue( self.instance.isRegistered( "v2" ) ) 
     
    5859        self.assertFalse( self.instance.isRegistered( "v1" ) ) 
    5960        self.assertTrue( self.instance.isRegistered( "v2" ) ) 
     61         
     62        self.assertRaises( pyxoo.exceptions.NoSuchElementException, self.instance.locate, "v1" ) 
     63        self.assertEquals( view, self.instance.locate( "v2" ) ) 
    6064         
    6165    def testLocate( self ):