/[thuban]/branches/WIP-pyshapelib-bramz/Thuban/Model/session.py
ViewVC logotype

Diff of /branches/WIP-pyshapelib-bramz/Thuban/Model/session.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 231 by bh, Wed Jul 17 10:50:40 2002 UTC revision 232 by bh, Fri Jul 19 15:14:57 2002 UTC
# Line 12  from Thuban.Lib.connector import Publish Line 12  from Thuban.Lib.connector import Publish
12    
13  from messages import MAPS_CHANGED, EXTENSIONS_CHANGED, FILENAME_CHANGED, \  from messages import MAPS_CHANGED, EXTENSIONS_CHANGED, FILENAME_CHANGED, \
14       LAYERS_CHANGED, MAP_PROJECTION_CHANGED, \       LAYERS_CHANGED, MAP_PROJECTION_CHANGED, \
15       LAYER_LEGEND_CHANGED, LAYER_PROJECTION_CHANGED, LAYER_VISIBILITY_CHANGED, \       LAYER_LEGEND_CHANGED, LAYER_PROJECTION_CHANGED, LAYER_VISIBILITY_CHANGED,\
16       EXTENSION_CHANGED, EXTENSION_OBJECTS_CHANGED       EXTENSION_CHANGED, EXTENSION_OBJECTS_CHANGED, CHANGED
17    
18  from base import TitledObject, Modifiable  from base import TitledObject, Modifiable
19    
# Line 39  class Session(TitledObject, Modifiable): Line 39  class Session(TitledObject, Modifiable):
39          LAYERS_CHANGED -- Same as the map's event of the same name.          LAYERS_CHANGED -- Same as the map's event of the same name.
40                            It's simply resent from the session to make                            It's simply resent from the session to make
41                            subscriptions easier.                            subscriptions easier.
42    
43            CHANGED -- Generic changed event. Parameters: the session. The
44                       event is always issued when any other changed event
45                       is issused. This is useful for code that needs to be
46                       notified whenever something in the session has
47                       changed but it's too cumbersome or error-prone to
48                       subscribe to all the individual events.
49      """      """
50    
51      # message channels that have to be forwarded from maps contained in      # message channels that have to be forwarded from maps contained in
# Line 65  class Session(TitledObject, Modifiable): Line 72  class Session(TitledObject, Modifiable):
72          self.tables = []          self.tables = []
73          self.extensions = []          self.extensions = []
74    
75        def changed(self, channel = None, *args):
76            """Like the inherited version but issue a CHANGED message as well.
77    
78            The CHANGED message is only issued if channel given is a
79            different channel than CHANGED.
80            """
81            Modifiable.changed(self, channel, *args)
82            if channel != CHANGED:
83                self.issue(CHANGED, self)
84    
85      def SetFilename(self, filename):      def SetFilename(self, filename):
86          self.filename = filename          self.filename = filename
87          self.changed(FILENAME_CHANGED)          self.changed(FILENAME_CHANGED)
# Line 101  class Session(TitledObject, Modifiable): Line 118  class Session(TitledObject, Modifiable):
118          Publisher.Destroy(self)          Publisher.Destroy(self)
119    
120      def forward(self, *args):      def forward(self, *args):
121          """Reissue events"""          """Reissue events.
122    
123            If the channel the event is forwarded to is a changed-channel
124            that is not the CHANGED channel issue CHANGED as well. An
125            channel is considered to be a changed-channel if it's name ends
126            with 'CHANGED'.
127            """
128          if len(args) > 1:          if len(args) > 1:
129              args = (args[-1],) + args[:-1]              args = (args[-1],) + args[:-1]
130          apply(self.issue, args)          apply(self.issue, args)
131            channel = args[0]
132            # It's a bit of a kludge to rely on the channel name for this.
133            if channel.endswith("CHANGED") and channel != CHANGED:
134                self.issue(CHANGED, self)
135    
136      def WasModified(self):      def WasModified(self):
137          """Return true if the session or one of the maps was modified"""          """Return true if the session or one of the maps was modified"""

Legend:
Removed from v.231  
changed lines
  Added in v.232

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26