Re: ReferenceField.get() and permissions

Felix Kurth <[email protected]>
Newsgroups gmane.comp.web.zope.plone.archetypes.devel
Message-ID <[email protected]>
> Wouldn't it be nicer to make 'here/getRef' return 'None' if the
> referenced object is not accessible? So that the template will be
> rendered correctly and just leave the reference out?

had the same Problem:
here is a workaround, that handles that better. Replace the function in
ReferenceEngine.py




def _resolveBrains(self, brains):
        objects = []
        if brains:
            for b in brains:
                obj = b.getObject()
                tobj = obj.getTargetObject()
                #Having the object is useless without at least View
permission on the target.
                if self.portal_membership.checkPermission('View',tobj):
                    objects.append(obj)
            objects = [b for b in objects if b]
        return objects


this is a "works for me" patch! be carefull.

greetings

Felix


> 
> -------------------------------------------------------
> This SF.net email is sponsored by Microsoft Mobile & Embedded DevCon 2005
> Attend MEDC 2005 May 9-12 in Vegas. Learn more about the latest Windows
> Embedded(r) & Windows Mobile(tm) platforms, applications & content. 
> Register by 3/29 & save $300
> http://ads.osdn.com/?ad_id=6883&alloc_id=15149&op=click




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.