[Zope-dev] Using zope.proxy for read-only instances

2008-12-22 Thread Andreas Jung
Hi there, I am trying to figure out how to use zope.proxy for creating read-only proxy objects of arbitrary Python objects where only attributes can be accessed read-only (no write access to attributes, no calling of methods). Anyone with some example code? Andreas begin:vcard fn:Andreas

Re: [Zope-dev] Using zope.proxy for read-only instances

2008-12-22 Thread Andreas Kopecky
Hi, My first question regarding that would be: why use zope.proxy for it. Personally - not knowing what exactly you have in mind ofc - i'd use something along the lines of class Proxy(object): def __init__(self, obj): self.obj = obj def __getattr__(self, attribute):

Re: [Zope-dev] Using zope.proxy for read-only instances

2008-12-22 Thread Andreas Jung
On 22.12.2008 11:34 Uhr, Andreas Kopecky wrote: Hi, My first question regarding that would be: why use zope.proxy for it. Personally - not knowing what exactly you have in mind ofc - i'd use something along the lines of class Proxy(object): def __init__(self, obj): self.obj =

Re: [Zope-dev] Using zope.proxy for read-only instances

2008-12-22 Thread Andreas Kopecky
Hi, Well if it's invalid i won't bother with it but say: - i forgot a self - that is true - if added it does NOT loop infinitely - its not my example its taken from python cookbook - it works with new style objects - __getattribute__ does something different But frankly i was only trying to