[Zope-dev] Using zope.proxy for read-only instances
    Andreas Kopecky 
    andreas.kopecky at meduniwien.ac.at
       
    Mon Dec 22 05:34:35 EST 2008
    
    
  
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):
        return getattr(obj, attribute)
maybe add a check of the returned attribute is callable or so.
Andreas
Andreas Jung wrote:
> 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
> 
> _______________________________________________
> Zope-Dev maillist  -  Zope-Dev at zope.org
> http://mail.zope.org/mailman/listinfo/zope-dev
> **  No cross posts or HTML encoding!  **
> (Related lists - 
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope )
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 549 bytes
Desc: OpenPGP digital signature
Url : http://mail.zope.org/pipermail/zope-dev/attachments/20081222/45a82fdd/attachment.bin 
    
    
More information about the Zope-Dev
mailing list