Ciao,
sto usando Plone-3.1.7, remember+membrane, e ho il mio custom member.
Vorrei mantenere il profilo dell'utente "privato" e, allo stesso tempo,
rendere visibile il portrait a chiunque, anche agli anonimi.
Ho provato così:
creato nuovo permesso in permissions.zcml:
<permission
id="my.product.ViewPortrait"
title="my.product: View member portrait"
/>
mappato i ruoli in rolemap.xml:
<permission name="my.product: View member portrait" acquire="False">
<role name="Anonymous" />
<role name="Authenticated" />
</permission>
Da ZMI il permesso risulta essere stato creato e mappato correttamente.
Ho anche aggiunto il permesso allo stato privato del WF abilitandolo per
"Anonymous" e "Authenticated".
(Ovviamente ho lanciato l'update security settings e ho controllato via pdb che
l'utente anonimo avesse il permesso).
Poi ho modificato il permesso del campo nella classe dell'oggetto:
[...]
schema['portrait'].read_permission = "my.product: View member portrait"
[...]
Veniamo al metodo per recuperare l'img:
def getPortraitFor(self, author):
portrait = author.getPortrait()
pm = getToolByName(self.context, 'portal_membership')
verify_perm = pm.checkPermission('informazionecasa.members: View member
portrait', portrait)
if verify_perm:
return portrait
return None
sembra funzionare correttamente dato che mi restituisce l'oggetto immagine.
Nel template ho provato sia questo
<metal:fieldMacro use-macro="python: author.widget('portrait', mode='read')" />
che non riproduce niente, nemmeno un errore, che questo
<img class="portraitPhoto" tal:attributes="src portrait/absolute_url;" />
che si "lamenta" con lo stesso errore che viene segnalato quando vado
direttamente al portrait tramite l'url:
2009-11-16 15:19:41 ERROR Zope.SiteErrorLog
http://localhost:8081/ic04/portal_memberdata/testuser/portrait/index_html
Traceback (innermost last):
Module ZPublisher.Publish, line 110, in publish
Module ZPublisher.BaseRequest, line 599, in traverse
Module ZPublisher.HTTPResponse, line 713, in unauthorized
Unauthorized: <strong>You are not authorized to access this
resource.</strong><p>
No Authorization header found.</p>
Non c'è verso di vedere l'immagine se non sei loggato...
Qualche suggerimento?
Grazie in anticipo,
simo
_______________________________________________
Plone-IT mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/plone-it
http://www.nabble.com/Plone---Italy-f21728.html