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

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

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

revision 1844 by bh, Tue Oct 21 10:49:44 2003 UTC revision 1970 by bh, Mon Nov 24 18:36:00 2003 UTC
# Line 149  class SessionLoader(XMLReader): Line 149  class SessionLoader(XMLReader):
149    
150          XMLReader.AddDispatchers(self, dispatchers)          XMLReader.AddDispatchers(self, dispatchers)
151    
152        def Destroy(self):
153            """Clear all instance variables to cut cyclic references.
154    
155            The GC would have collected the loader eventually but it can
156            happen that it doesn't run at all until Thuban is closed (2.3
157            but not 2.2 tries a bit harder and forces a collection when the
158            interpreter terminates)
159            """
160            self.__dict__.clear()
161    
162      def start_session(self, name, qname, attrs):      def start_session(self, name, qname, attrs):
163          self.theSession = Session(self.encode(attrs.get((None, 'title'),          self.theSession = Session(self.encode(attrs.get((None, 'title'),
164                                                          None)))                                                          None)))
# Line 176  class SessionLoader(XMLReader): Line 186  class SessionLoader(XMLReader):
186          If the attribute has a default value and it is not present in          If the attribute has a default value and it is not present in
187          attrs, use that default value as the value in the returned dict.          attrs, use that default value as the value in the returned dict.
188    
189          If a conversion is specified, convert the value before putting          The value is converted before putting it into the returned dict.
190          it into the returned dict. The following conversions are          The following conversions are available:
         available:  
191    
192             'filename' -- The attribute is a filename.             'filename' -- The attribute is a filename.
193    
# Line 202  class SessionLoader(XMLReader): Line 211  class SessionLoader(XMLReader):
211                        ascii encoding.                        ascii encoding.
212    
213             a callable -- The attribute value is passed to the callable             a callable -- The attribute value is passed to the callable
214                           and the return value is used a as the converted                           and the return value is used as the converted
215                           value                           value
216    
217            If no conversion is specified for an attribute it is converted
218            with self.encode.
219          """          """
220          normalized = {}          normalized = {}
221    
# Line 237  class SessionLoader(XMLReader): Line 249  class SessionLoader(XMLReader):
249              elif d.conversion:              elif d.conversion:
250                  # Assume it's a callable                  # Assume it's a callable
251                  value = d.conversion(value)                  value = d.conversion(value)
252                else:
253                   value = self.encode(value)
254    
255              normalized[d.name] = value              normalized[d.name] = value
256          return normalized          return normalized
# Line 436  class SessionLoader(XMLReader): Line 450  class SessionLoader(XMLReader):
450          self.aLayer = None          self.aLayer = None
451    
452      def start_classification(self, name, qname, attrs):      def start_classification(self, name, qname, attrs):
453          field = attrs.get((None, 'field'), None)          attrs = self.check_attrs(name, attrs,
454                                     [AttrDesc("field", True),
455                                      AttrDesc("field_type", True)])
456            field = attrs["field"]
457            fieldType = attrs["field_type"]
458    
         fieldType = attrs.get((None, 'field_type'), None)  
459          dbFieldType = self.aLayer.GetFieldType(field)          dbFieldType = self.aLayer.GetFieldType(field)
460    
461          if fieldType != dbFieldType:          if fieldType != dbFieldType:
# Line 559  def load_session(filename, db_connection Line 576  def load_session(filename, db_connection
576      # Newly loaded session aren't modified      # Newly loaded session aren't modified
577      session.UnsetModified()      session.UnsetModified()
578    
579        handler.Destroy()
580    
581      return session      return session
582    

Legend:
Removed from v.1844  
changed lines
  Added in v.1970

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26