[Thuban-devel] Re: RfD: Support for layer specific resources

Bernhard Herzog bh at intevation.de
Wed Aug 4 19:35:12 CEST 2004


Martin Schulze <joey at infodrom.org> writes:

> Bernhard Herzog wrote:
>> Yes. Only nit: Please don't use "object" as identifier in new code.
>> It's a Python builtin.
>
> Oh, sorry.  I wonder why Python didn't complain, though.

Builtins aren't keywords.  The builtins are simply the last scope where
python looks when trying to resolve a name.  Hence it's no error to use
the name of a builtin as an identifier.  It can be a bit confusing
though, and should generally be avoided when writing code.

> In order to use the new ClassMapper I'd assume that we'll need
> something like the following:
>
>
> from Thuban.Lib.classmapper import ClassMapper
>
> _properties_dialogs = ClassMapper()
>
> def add_properties_dialog(layer_class, dialog_class):
>     _properties_dialogs.add(layer_class, dialog_class)
>
> def get_properties_dialog_class(layer):
>     return _properties_dialogs.get(layer)

I think in practice only the mainwindow code will look up the dialogs,
so I'd say, the mapper should be in Thuban/UI/mainwindow.py.  I'd also
omit the extra functions a simple

from Thuban.Lib.classmapper import ClassMapper

layer_properties_dialogs = ClassMapper()


should suffice.


> And for Thuban.UI.classifier:
>
> add_properties_dialog(Layer, Classifier)
> add_properties_dialog(RasterLayer, Classifier)
> 
> 
> as well as for Thuban.UI.mainwindow:
>
>
>     def OpenLayerProperties(self, layer, group = None):
>         dialog_class = get_properties_dialog_class(layer)
>
>         if dialog_class is not None:
>             name = "layer_properties" + str(id(layer))
>             self.OpenOrRaiseDialog(name, dialog_class, layer, group = group)
>
> Right?


Yes, after adapting to my suggestion above.

   Bernhard

-- 
Intevation GmbH                                 http://intevation.de/
Skencil                                http://sketch.sourceforge.net/
Thuban                                  http://thuban.intevation.org/




More information about the Thuban-devel mailing list

This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)