[Zope-CMF] addActionProvider

Thomas Olsen tol@tanghus.dk
Tue, 27 Aug 2002 10:51:03 +0200


On Tuesday August 27 2002 10:24, Thomas Olsen wrote:
>     def addActionProvider( self, provider_name ):
>         """ add the name of a new action provider """
>         if hasattr( self, provider_name ) \
>           and not provider_name in self.action_providers:
>             p_old =3D self.action_providers
>             p_new =3D p_old.append(provider_name)
>             self.action_providers =3D p_new

Oops - this made me loose all my action providers.
This seems to work a bit better:

    def addActionProvider( self, provider_name ):
        """ add the name of a new action provider """
        ap =3D self.action_providers
        if type(ap) is not type([]) and type(ap) is not type(()):
            ap =3D []
        if hasattr( self, provider_name ) \
          and not provider_name in ap:
            ap.append(provider_name)
            self.action_providers =3D ap


--=20
Regards,
=09Thomas Olsen