[Thuban-devel] Re: RfD: Support for layer specific resources
Martin Schulze
joey at infodrom.org
Tue Jun 15 21:02:00 CEST 2004
Bernhard Herzog wrote:
> > _layer_dialogs = {}
> >
> >
> > def add_layer_dialog(type, layer_class, dialog_class):
> > try:
> > _layer_dialogs[type].append((layer_class, dialog_class))
> > except KeyError:
> > _layer_dialogs[type] = [(layer_class, dialog_class)]
> >
> >
> > def init_layer_dialogs(type):
> > try:
> > del _layer_dialogs[type][:]
> > except KeyError:
> > pass
> >
> >
> > def has_layer_dialog(type, layer_class):
> > for cls, dialog_class in _layer_dialogs[type]:
> > if cls == layer_class:
> > return True
> > return False
> >
> >
> > def get_layer_dialog_class(type, layer):
> > for layer_class, dialog_class in _layer_dialogs['properties']:
> > if isinstance(layer, layer_class):
> > return dialog_class
> > return None
> >
> >
> > def get_layer_properties_class(layer):
> > return get_layer_dialog_class('properties', layer)
>
>
> I'd prefer a different approach for different types of dialogs. There
> should be one class that implements the mapping from class instances to
> the objects associated with classes (in this case from layer instances
> to the property dialog classes). There would be one instance for the
> layer property dialogs and one for the renderers. If we need more layer
> type specific things we can create more instances.
Are you looking for something like this?
class foo:
def __init__(self):
_mapping = []
def register_class_dialog(self, class, dlg_class):
_mapping.append((class, dlg_class))
def get_dialog_class(self, instance):
return proper_class
def has_dialoc_class(self, instance):
return true or false
Regards,
Joey
--
MIME - broken solution for a broken design. -- Ralf Baechle
More information about the Thuban-devel
mailing list
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)