Le 8 nov. 2010 à 15:34, Simone Orsi a écrit :

> On 11/08/2010 03:09 PM, Wichert Akkerman wrote:
>> On 11/8/10 14:51 , Simone Orsi wrote:
>>> On 11/08/2010 11:14 AM, Gilles Lenfant wrote:
>>>> Le 8 nov. 2010 à 10:18, Simone Orsi a écrit :
>>>> 
>>>>> hi,
>>>>> 
>>>>> I need to create a product that deletes any user's content on user
>>>>> deletion. I googled and grepped here and there and it seems there's no
>>>>> event fired on user deletion.
>>>>> 
>>>>> The only "right way" to do that seems to create an IUserManager PAS
>>>>> plugin to handle it but IMHO that means much work to be done only to
>>>>> have an event hook. The other solution, obviously, is monkey-patching,
>>>>> which becomes even more bad since that part of PluggableAuthServ is
>>>>> already patched by PlonePAS.
>>>>> 
>>>>> Is this right? Do I have to create a plugin?
>>>> 
>>>> Hi,
>>>> 
>>>> I ran into this some times ago. See https://dev.plone.org/plone/ticket/7948
>>>> 
>>>> Was not for content but for user properties. Seems that Tarek Ziade 
>>>> started something in the Zope dev ML (PAS is a Zope hosted component) but 
>>>> I dunno the progress status.
>>>> 
>>>> Note that it is very difficult to handle users from external sources 
>>>> deletion  (LDAP, RDBMS, ...) since there's no event bus that goes to Zope.
>>>> 
>>>> Cheers
>>> 
>>> hi Gilles,
>>> 
>>> thank for the link. Why is so difficult? I mean, what is needed IMO is
>>> an event hook on the plone/zope side which gets triggered everytime a
>>> user is deleted, non matter the source of the deletion. Am I missing
>>> some inner implication?
>> 
>> How do you expect Plone to know about a user being deleted in an active 
>> directory database? Or when someone deletes an OpenID identity?
>> 
>> Wichert.
> 
> I apologize, you are right Wichert. Anyway, the usecase I refer to does
> not include deleting users from the source. So, I think I have to write
> my custom plugin to handle my usecase.

Sure, you may subclass the Products.PlonePAS.plugins.user.UserManager class or 
any better suited user source plugin class that implements IUserManagement, and 
do this :

class ISomeUserDeleted(Interface):
  """Event triggerd at user removal"""
  login = Attribute("login that's already successfully deleted")

class SomeUserDeleted(object):
  implements(ISomeUserDeleted)
  def __init__(self, login):
    self.login = login

class MyUserSource(UserManager):
...
  def doDeleteUser(self, login):
    super(MyUserSource, self).doDeleteUser(login)
    notify(SomeUserDeleted(login))
    ...

With appropriate imports of course. Then handle the "SomeUserDeleted" event in 
whatever you want.

Cheers
-- 
Gilles Lenfant

_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers

Reply via email to