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

Martin Schulze joey at infodrom.org
Tue Jul 13 16:18:46 CEST 2004


Hi Bernhard!

Hope you and the team had enjoyed LinuxTag and you're all fine back.

Bernhard Herzog wrote:
> > 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
> 
> Yes.  Although the names shouldn't be specific to dialogs.  The class
> should be usable for the renderes too.

Looks like you could want the following?

class Mapping:
    "Implements a mapping of class pairs

    def __init__(self):
        _mapping = []

    def register_class(self, key_class, client_class):
        _mapping.append((key_class, client_class))

    def get_class(self, instance):
        for key_class, client_class in _mapping:
            if isinstance(instance, key_class):
                return client_class
        return None

    def has_dialog_class(self, instance):
        if self.get_class(instance) is not None:
            return true
        return false


The code is not yet tested, though.

Regards,

	Joey

-- 
If nothing changes, everything will remain the same.  -- Barne's Law




More information about the Thuban-devel mailing list

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