[Zope3-Users] Re: how to know if a principal has the right permissions

Lorenzo Gil Sanchez lgs at sicem.biz
Mon Aug 28 14:20:33 EDT 2006


El dom, 27-08-2006 a las 23:53 +0200, Philipp von Weitershausen
escribió:

> zope.security.canAccess
> zope.security.canWrite

Nice, I didn't know about those and I ended writing my own solution:

    def canAdd(self):
        interaction = ZopeSecurityPolicy()
        interaction.add(Participation(self.request.principal))
        return interaction.checkPermission("zope.ManageContent",
self.context)

I'm trying to know if the user can add an item to a container. I don't
know how to do that with zope.security.canWrite. I tried with

zope.security.canWrite(self.context, '__data') 

since my container inherits from SampleContainer and the '__data'
attribute is a dictionariy like objet where the children are stored. I
get a ForbiddenAttribute exception with that code.




More information about the Zope3-users mailing list