Projet

Général

Profil

Télécharger (1,13 ko) Statistiques
| Branche: | Révision:

root / larpe / tags / release-1.1.1 / larpe / plugins / site_authentication_plugins.py @ d03cb81c

1

    
2
class SiteAuthenticationPlugins:
3
    """ This class manages the plugins for site authentification """
4

    
5
    def __init__(self):
6
        self.site_authentication_classes = dict()
7

    
8
    def register(self, klass):
9
        """ Register a custom SiteAuthentification instance """
10
        self.site_authentication_classes[klass.plugin_name] = klass
11

    
12
    def get(self, plugin_name):
13
        """ Return a custom SiteAuthentification instance """
14
        if self.site_authentication_classes.has_key(plugin_name):
15
            return self.site_authentication_classes[plugin_name]
16
        else:
17
            return None
18

    
19
    def get_plugins_name(self):
20
        plugins_name = list()
21
        for plugin_name in self.site_authentication_classes.iterkeys():
22
            plugins_name.append(plugin_name)
23
        return plugins_name
24

    
25
    def auto_detect(self, html_doc):
26
        """
27
        Try to find automatically the right plugin name
28
        Return the plugin name or None
29
        """
30
        for name, klass in self.site_authentication_classes.iteritems():
31
            if klass.auto_detect_site(html_doc):
32
                return klass.plugin_name
33
        return None
34

    
(2-2/2)