Security problem when accessing object instance in a product
Hello, I'm currently working on Maildir product which may provide access to my mails. I've defined a class to access this maildir : from Maildirlib import Maildir class ZMaildir(Implicit, Persistent, RoleManager, Item) : """ Classe implémentant un composant Maildir """ meta_type = 'ZMaildir' security = ClassSecurityInfo() def __init__(self, id, path) : self.id = id self.path = path self._messages = {} self._populate() security.declareProtected('View content', 'GetMailList') def GetMailList(self) : """ Retourne la liste des mails """ lst = [] for i in self._messages.keys() : lst.append(self._messages[i]) return lst def _populate(self) : maildir = Maildir(self.path) mail_p = maildir.next() while mail_p : self._messages[mail_p.msgID] = mail_p mail_p = maildir.next() self._p_changed = 1 GetMailList returns the right list with some Maildir.Message in it. When I try to access the Maildir.Message.headers variable I've got this error : You are not allowed to access headers in this context but I have declared headers public : class Message : security = ClassSecurityInfo() security.declarePublic('headers') Here is the way I try to access headers : http://localhost:9673/nicoe/voir_mail/inbox/voir_maillist where voir_maillist is a ZPT with <TR tal:repeat="item here/GetMailList"> <TD tal:content="item/headers/from">From</TD> <TD tal:content="item/headers/to">To</TD> <TD tal:content="item/headers/subject">Sujet</TD> </TR> Sorry for the long explanation, I hope I don't polute too much the list ... -- (°> Nicolas Évrard / ) Liège - Belgique ^^
Nicolas Évrard wrote:
but I have declared headers public :
class Message : security = ClassSecurityInfo() security.declarePublic('headers')
have you done: Globals.InitializeClass(Message) ...afterwards? cheers, Chris
* Chris Withers [14:33 31/08/02 CEST]:
Nicolas Évrard wrote:
but I have declared headers public :
class Message : security = ClassSecurityInfo() security.declarePublic('headers')
have you done:
Globals.InitializeClass(Message)
...afterwards?
Finally, I got it working by doing so (thanks) and defining a method headers to return the content of self.header But now, my template looks like this <TD tal:content="python:item.headers()['from']">From</TD> which is inestetic, but I guess I must carry on ... -- (°> Nicolas Évrard / ) Liège - Belgique ^^
participants (2)
-
Chris Withers -
Nicolas Évrard