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))) |
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 |
|
|
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 |
|
|
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 |
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: |
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 |
|
|